74 document.getElementsByTagName('head')[0].appendChild(css); |
74 document.getElementsByTagName('head')[0].appendChild(css); |
75 }})()""" |
75 }})()""" |
76 |
76 |
77 style = css.replace("'", "\\'").replace("\n", "\\n") |
77 style = css.replace("'", "\\'").replace("\n", "\\n") |
78 return source.format(style) |
78 return source.format(style) |
|
79 |
|
80 |
|
81 def toggleMediaPause(pos): |
|
82 """ |
|
83 Function generating a script to toggle the paused state of a media element. |
|
84 |
|
85 @param pos position of the media element |
|
86 @type QPoint |
|
87 @return script to toggle the element paused state |
|
88 @rtype str |
|
89 """ |
|
90 source = """ |
|
91 (function() {{ |
|
92 var e = document.elementFromPoint({0}, {1}); |
|
93 if (!e) |
|
94 return; |
|
95 if (e.paused) |
|
96 e.play(); |
|
97 else |
|
98 e.pause(); |
|
99 }})()""" |
|
100 return source.format(pos.x(), pos.y()) |
|
101 |
|
102 |
|
103 def toggleMediaMute(pos): |
|
104 """ |
|
105 Function generating a script to toggle the mute state of a media element. |
|
106 |
|
107 @param pos position of the media element |
|
108 @type QPoint |
|
109 @return script to toggle the element mute state |
|
110 @rtype str |
|
111 """ |
|
112 source = """ |
|
113 (function() {[ |
|
114 var e = document.elementFromPoint({0}, {1}); |
|
115 if (!e) |
|
116 return; |
|
117 e.muted = !e.muted; |
|
118 }})()""" |
|
119 return source.format(pos.x(), pos.y()) |