Skip to content

Commit

Permalink
fix(player): load method fails to reset the media element to its init…
Browse files Browse the repository at this point in the history
…ial state when the VHS is used (#8274)
  • Loading branch information
amtins authored May 31, 2023
1 parent 665154f commit 35fad1d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -3533,6 +3533,14 @@ class Player extends Component {
* Begin loading the src data.
*/
load() {
// Workaround to use the load method with the VHS.
// Does not cover the case when the load method is called directly from the mediaElement.
if (this.tech_.vhs) {
this.src(this.currentSource());

return;
}

this.techCall_('load');
}

Expand Down
28 changes: 28 additions & 0 deletions test/unit/player.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3231,6 +3231,34 @@ QUnit.test('turning on audioPosterMode when audioOnlyMode is already on will tur
});
});

QUnit.test('player#load resets the media element to its initial state', function(assert) {
const player = TestHelpers.makePlayer({});

player.src({ src: 'http://vjs.zencdn.net/v/oceans2.mp4', type: 'video/mp4' });

// Declaring spies here avoids spying on previous calls
const techGet_ = sinon.spy(player, 'techCall_');
const src = sinon.spy(player, 'src');

player.load();

// Case when the VHS tech is not used
assert.ok(techGet_.calledOnce, 'techCall_ was called once');
assert.ok(src.notCalled, 'src was not called');

// Simulate the VHS tech
player.tech_.vhs = true;
player.load();

// Case when the VHS tech is used
assert.ok(techGet_.calledOnce, 'techCall_ remains the same');
assert.ok(src.calledOnce, 'src was called');

techGet_.restore();
src.restore();
player.dispose();
});

QUnit.test('crossOrigin value should be maintained after loadMedia is called', function(assert) {
const fixture = document.getElementById('qunit-fixture');

Expand Down

0 comments on commit 35fad1d

Please sign in to comment.