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: have reloadSourceOnError get src from player #893

Merged
merged 4 commits into from
Jul 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/reload-source-on-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const defaultOptions = {
errorInterval: 30,
getSource(next) {
const tech = this.tech({ IWillNotUseThisInPlugins: true });
const sourceObj = tech.currentSource_;
const sourceObj = tech.currentSource_ || this.currentSource();

return next(sourceObj);
}
Expand Down
27 changes: 27 additions & 0 deletions test/reload-source-on-error.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,35 @@ QUnit.test('triggers on player error', function(assert) {
assert.deepEqual(
this.player.src.calledWith[0],
this.tech.currentSource_,
'player.src was called with tech.currentSource_'
);
});

QUnit.test('triggers on player error, uses player.currentSource() if tech.currentSource_ is not set', function(assert) {
const oldsrc = this.tech.currentSource_;
const src = {
src: 'thisisanothersource.m3u8',
type: 'video/mp4'
};

this.tech.currentSource_ = null;
this.player.currentSource = () => src;

this.player.reloadSourceOnError();
this.player.trigger('error', -2);

assert.equal(this.player.src.calledWith.length, 1, 'player.src was only called once');
assert.deepEqual(
this.player.src.calledWith[0],
src,
'player.src was called with player.currentSource'
);

assert.notDeepEqual(
this.player.src.calledWith[0],
oldsrc,
'player.src was called with player.currentSource() and not tech.currentSource_'
);
});

QUnit.test('seeks to currentTime in VOD', function(assert) {
Expand Down