Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: stutter after fast quality change in IE/Edge #213

Merged
merged 9 commits into from
Sep 21, 2018
45 changes: 33 additions & 12 deletions test/master-playlist-controller.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,81 +376,102 @@ QUnit.test('resets everything for a fast quality change', function(assert) {
});

QUnit.test('seeks in place for fast quality switch on non-IE/Edge browsers', function(assert) {
let seeks = 0;

this.masterPlaylistController.mediaSource.trigger('sourceopen');
// master
this.standardXHRResponse(this.requests.shift());
// media
this.standardXHRResponse(this.requests.shift());
// segment
this.standardXHRResponse(this.requests.shift());
this.masterPlaylistController.mediaSource.sourceBuffers[0].trigger('updateend');

// media is changed
this.masterPlaylistController.selectPlaylist = () => {
return this.masterPlaylistController.master().playlists[0];
};

// makes sure the resetEverything callback is queued when sourceUpdater_.remove() gets called
this.masterPlaylistController.mainSegmentLoader_.sourceUpdater_.processedAppend_ = true;
this.player.tech_.on('seeking', function() {
seeks++;
});

const timeBeforeSwitch = this.player.currentTime();

this.masterPlaylistController.fastQualityChange_();

this.masterPlaylistController.mediaSource.sourceBuffers[0].trigger('updateend');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this responding to an actual "append?" I think if the fastQualityChange happened, there would still have to be a segment request before an append would happen.

this.clock.tick(1);

assert.equal(this.player.currentTime(), timeBeforeSwitch, 'seeks in place on fast quality switch');
assert.equal(this.player.currentTime(), timeBeforeSwitch, 'current time remains the same on fast quality switch');
assert.equal(seeks, 1, 'seek event occurs on fast quality switch');
});

QUnit.test('seeks forward 0.04 sec for fast quality switch on Edge', function(assert) {
let seeks = 0;

this.masterPlaylistController.mediaSource.trigger('sourceopen');
// master
this.standardXHRResponse(this.requests.shift());
// media
this.standardXHRResponse(this.requests.shift());
// segment
this.standardXHRResponse(this.requests.shift());
this.masterPlaylistController.mediaSource.sourceBuffers[0].trigger('updateend');

// media is changed
this.masterPlaylistController.selectPlaylist = () => {
return this.masterPlaylistController.master().playlists[0];
};

// makes sure the resetEverything callback is queued when sourceUpdater_.remove() gets called
this.masterPlaylistController.mainSegmentLoader_.sourceUpdater_.processedAppend_ = true;
this.player.tech_.on('seeking', function() {
seeks++;
});

const timeBeforeSwitch = this.player.currentTime();

videojs.browser.IE_VERSION = null;
gesinger marked this conversation as resolved.
Show resolved Hide resolved
videojs.browser.IS_EDGE = true;

this.masterPlaylistController.fastQualityChange_();

this.masterPlaylistController.mediaSource.sourceBuffers[0].trigger('updateend');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

this.clock.tick(1);

assert.equal(this.player.currentTime(), timeBeforeSwitch + 0.04, 'seeks in place on fast quality switch');
assert.equal(this.player.currentTime(), timeBeforeSwitch + 0.04, 'seeks forward on fast quality switch');
assert.equal(seeks, 1, 'seek event occurs on fast quality switch');
});

QUnit.test('seeks forward 0.04 sec for fast quality switch on IE', function(assert) {
let seeks = 0;

this.masterPlaylistController.mediaSource.trigger('sourceopen');
// master
this.standardXHRResponse(this.requests.shift());
// media
this.standardXHRResponse(this.requests.shift());
// segment
this.standardXHRResponse(this.requests.shift());
this.masterPlaylistController.mediaSource.sourceBuffers[0].trigger('updateend');

// media is changed
this.masterPlaylistController.selectPlaylist = () => {
return this.masterPlaylistController.master().playlists[0];
};

// makes sure the resetEverything callback is queued when sourceUpdater_.remove() gets called
this.masterPlaylistController.mainSegmentLoader_.sourceUpdater_.processedAppend_ = true;
this.player.tech_.on('seeking', function() {
seeks++;
});

const timeBeforeSwitch = this.player.currentTime();

videojs.browser.IE_VERSION = 11;
videojs.browser.IS_EDGE = false;

this.masterPlaylistController.fastQualityChange_();

this.masterPlaylistController.mediaSource.sourceBuffers[0].trigger('updateend');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

this.clock.tick(1);

assert.equal(this.player.currentTime(), timeBeforeSwitch + 0.04, 'seeks in place on fast quality switch');
assert.equal(this.player.currentTime(), timeBeforeSwitch + 0.04, 'seeks forward on fast quality switch');
assert.equal(seeks, 1, 'seek event occurs on fast quality switch');
});

QUnit.test('audio segment loader is reset on audio track change', function(assert) {
Expand Down