OLD | NEW |
1 var captionsButtonElement; | 1 var captionsButtonElement; |
2 var captionsButtonCoordinates; | 2 var captionsButtonCoordinates; |
3 | 3 |
4 // As specified in mediaControls.css, this is how long it takes to fade out cont
rols | 4 // As specified in mediaControls.css, this is how long it takes to fade out cont
rols |
5 const controlsFadeOutDurationMs = 300; | 5 const controlsFadeOutDurationMs = 300; |
6 | 6 |
7 // The timeout for the hide-after-no-mouse-movement behavior. Defined (and | 7 // The timeout for the hide-after-no-mouse-movement behavior. Defined (and |
8 // should mirror) the value 'timeWithoutMouseMovementBeforeHidingMediaControls' | 8 // should mirror) the value 'timeWithoutMouseMovementBeforeHidingMediaControls' |
9 // in MediaControls.cpp. | 9 // in MediaControls.cpp. |
10 const controlsMouseMovementTimeoutMs = 3000; | 10 const controlsMouseMovementTimeoutMs = 3000; |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 } | 167 } |
168 | 168 |
169 function selectTextTrack(video, index) | 169 function selectTextTrack(video, index) |
170 { | 170 { |
171 clickCCButton(); | 171 clickCCButton(); |
172 var trackListItemElement = textTrackListItemAtIndex(video, index); | 172 var trackListItemElement = textTrackListItemAtIndex(video, index); |
173 var trackListItemCoordinates = elementCoordinates(trackListItemElement); | 173 var trackListItemCoordinates = elementCoordinates(trackListItemElement); |
174 clickAtCoordinates(trackListItemCoordinates[0], trackListItemCoordinates[1])
; | 174 clickAtCoordinates(trackListItemCoordinates[0], trackListItemCoordinates[1])
; |
175 } | 175 } |
176 | 176 |
| 177 function selectTextTrackAtIndex(video, index) |
| 178 { |
| 179 var captionsButtonCoordinates = mediaControlsButtonCoordinates(video, "toggl
e-closed-captions-button"); |
| 180 clickAtCoordinates(captionsButtonCoordinates[0], captionsButtonCoordinates[1
]); |
| 181 var trackListItemElement = textTrackListItemAtIndex(video, index); |
| 182 var trackListItemCoordinates = elementCoordinates(trackListItemElement); |
| 183 clickAtCoordinates(trackListItemCoordinates[0], trackListItemCoordinates[1])
; |
| 184 } |
| 185 |
177 function turnClosedCaptionsOff(video) | 186 function turnClosedCaptionsOff(video) |
178 { | 187 { |
179 selectTextTrack(video, -1); | 188 selectTextTrackAtIndex(video, -1); |
180 } | 189 } |
181 | 190 |
182 function runAfterHideMediaControlsTimerFired(func, mediaElement) | 191 function runAfterHideMediaControlsTimerFired(func, mediaElement) |
183 { | 192 { |
184 if (mediaElement.paused) | 193 if (mediaElement.paused) |
185 throw "The media element is not playing"; | 194 throw "The media element is not playing"; |
186 | 195 |
187 // Compute the time it'll take until the controls will be invisible - | 196 // Compute the time it'll take until the controls will be invisible - |
188 // assuming playback has been started prior to invoking this | 197 // assuming playback has been started prior to invoking this |
189 // function. Allow 500ms slack. | 198 // function. Allow 500ms slack. |
190 var hideTimeoutMs = controlsMouseMovementTimeoutMs + controlsFadeOutDuration
Ms + 500; | 199 var hideTimeoutMs = controlsMouseMovementTimeoutMs + controlsFadeOutDuration
Ms + 500; |
191 | 200 |
192 if (!mediaElement.loop && hideTimeoutMs >= 1000 * (mediaElement.duration - m
ediaElement.currentTime)) | 201 if (!mediaElement.loop && hideTimeoutMs >= 1000 * (mediaElement.duration - m
ediaElement.currentTime)) |
193 throw "The media will end before the controls have been hidden"; | 202 throw "The media will end before the controls have been hidden"; |
194 | 203 |
195 setTimeout(func, hideTimeoutMs); | 204 setTimeout(func, hideTimeoutMs); |
196 } | 205 } |
OLD | NEW |