Convert seeking implementation to currentTime
Instead of listening for the seeking event, override the currentTime implementation on the tech. Update the tests.
Showing
2 changed files
with
15 additions
and
15 deletions
... | @@ -190,13 +190,19 @@ var | ... | @@ -190,13 +190,19 @@ var |
190 | updateDuration; | 190 | updateDuration; |
191 | 191 | ||
192 | 192 | ||
193 | player.on('seeking', function() { | 193 | player.hls.currentTime = function(currentTime) { |
194 | var currentTime = player.currentTime(); | 194 | if (currentTime === undefined) { |
195 | player.hls.mediaIndex = getMediaIndexByTime(player.hls.playlists.media(), | 195 | return this.el().vjs_getProperty('currentTime'); |
196 | currentTime); | 196 | } |
197 | |||
198 | if (!(this.playlists && this.playlists.media())) { | ||
199 | return 0; | ||
200 | } | ||
201 | this.mediaIndex = | ||
202 | getMediaIndexByTime(this.playlists.media(), currentTime); | ||
197 | 203 | ||
198 | // abort any segments still being decoded | 204 | // abort any segments still being decoded |
199 | player.hls.sourceBuffer.abort(); | 205 | this.sourceBuffer.abort(); |
200 | 206 | ||
201 | // cancel outstanding requests and buffer appends | 207 | // cancel outstanding requests and buffer appends |
202 | if (segmentXhr) { | 208 | if (segmentXhr) { |
... | @@ -205,7 +211,7 @@ var | ... | @@ -205,7 +211,7 @@ var |
205 | 211 | ||
206 | // begin filling the buffer at the new position | 212 | // begin filling the buffer at the new position |
207 | fillBuffer(currentTime * 1000); | 213 | fillBuffer(currentTime * 1000); |
208 | }); | 214 | }; |
209 | 215 | ||
210 | /** | 216 | /** |
211 | * Update the player duration | 217 | * Update the player duration | ... | ... |
... | @@ -754,7 +754,7 @@ test('cancels outstanding XHRs when seeking', function() { | ... | @@ -754,7 +754,7 @@ test('cancels outstanding XHRs when seeking', function() { |
754 | // trigger a segment download request | 754 | // trigger a segment download request |
755 | player.trigger('timeupdate'); | 755 | player.trigger('timeupdate'); |
756 | // attempt to seek while the download is in progress | 756 | // attempt to seek while the download is in progress |
757 | player.trigger('seeking'); | 757 | player.hls.currentTime(7); |
758 | 758 | ||
759 | ok(requests[1].aborted, 'XHR aborted'); | 759 | ok(requests[1].aborted, 'XHR aborted'); |
760 | strictEqual(requests.length, 3, 'opened new XHR'); | 760 | strictEqual(requests.length, 3, 'opened new XHR'); |
... | @@ -830,10 +830,7 @@ test('drops tags before the target timestamp when seeking', function() { | ... | @@ -830,10 +830,7 @@ test('drops tags before the target timestamp when seeking', function() { |
830 | bytes: i | 830 | bytes: i |
831 | }); | 831 | }); |
832 | } | 832 | } |
833 | player.currentTime = function() { | 833 | player.hls.currentTime(7); |
834 | return 7; | ||
835 | }; | ||
836 | player.trigger('seeking'); | ||
837 | standardXHRResponse(requests[2]); | 834 | standardXHRResponse(requests[2]); |
838 | 835 | ||
839 | while (callbacks.length) { | 836 | while (callbacks.length) { |
... | @@ -879,10 +876,7 @@ test('clears pending buffer updates when seeking', function() { | ... | @@ -879,10 +876,7 @@ test('clears pending buffer updates when seeking', function() { |
879 | 876 | ||
880 | // seek to 7s | 877 | // seek to 7s |
881 | tags.push({ pts: 7000, bytes: 7 }); | 878 | tags.push({ pts: 7000, bytes: 7 }); |
882 | player.currentTime = function() { | 879 | player.hls.currentTime(7); |
883 | return 7; | ||
884 | }; | ||
885 | player.trigger('seeking'); | ||
886 | standardXHRResponse(requests[2]); | 880 | standardXHRResponse(requests[2]); |
887 | 881 | ||
888 | while (callbacks.length) { | 882 | while (callbacks.length) { | ... | ... |
-
Please register or sign in to post a comment