dc2fa763 by David LaPalomento

Convert seeking implementation to currentTime

Instead of listening for the seeking event, override the currentTime implementation on the tech. Update the tests.
1 parent d30df95f
......@@ -190,13 +190,19 @@ var
updateDuration;
player.on('seeking', function() {
var currentTime = player.currentTime();
player.hls.mediaIndex = getMediaIndexByTime(player.hls.playlists.media(),
currentTime);
player.hls.currentTime = function(currentTime) {
if (currentTime === undefined) {
return this.el().vjs_getProperty('currentTime');
}
if (!(this.playlists && this.playlists.media())) {
return 0;
}
this.mediaIndex =
getMediaIndexByTime(this.playlists.media(), currentTime);
// abort any segments still being decoded
player.hls.sourceBuffer.abort();
this.sourceBuffer.abort();
// cancel outstanding requests and buffer appends
if (segmentXhr) {
......@@ -205,7 +211,7 @@ var
// begin filling the buffer at the new position
fillBuffer(currentTime * 1000);
});
};
/**
* Update the player duration
......
......@@ -754,7 +754,7 @@ test('cancels outstanding XHRs when seeking', function() {
// trigger a segment download request
player.trigger('timeupdate');
// attempt to seek while the download is in progress
player.trigger('seeking');
player.hls.currentTime(7);
ok(requests[1].aborted, 'XHR aborted');
strictEqual(requests.length, 3, 'opened new XHR');
......@@ -830,10 +830,7 @@ test('drops tags before the target timestamp when seeking', function() {
bytes: i
});
}
player.currentTime = function() {
return 7;
};
player.trigger('seeking');
player.hls.currentTime(7);
standardXHRResponse(requests[2]);
while (callbacks.length) {
......@@ -879,10 +876,7 @@ test('clears pending buffer updates when seeking', function() {
// seek to 7s
tags.push({ pts: 7000, bytes: 7 });
player.currentTime = function() {
return 7;
};
player.trigger('seeking');
player.hls.currentTime(7);
standardXHRResponse(requests[2]);
while (callbacks.length) {
......