Skip to content

Commit

Permalink
fix(player): techGet is undefined
Browse files Browse the repository at this point in the history
Fixes #8255
  • Loading branch information
amtins committed Apr 30, 2023
1 parent 1491d71 commit cf39dee
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -1613,7 +1613,7 @@ class Player extends Component {
return;
}

const techSrc = this.techGet('currentSrc');
const techSrc = this.techGet_('currentSrc');

this.lastSource_.tech = techSrc;
this.updateSourceCaches_(techSrc);
Expand Down
36 changes: 36 additions & 0 deletions test/unit/sourceset.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1194,4 +1194,40 @@ QUnit[qunitFn]('sourceset', function(hooks) {
player.src(youtubeSrc);

});

QUnit.test('tech sourceset update sources cache when changingSrc_ is false', function(assert) {
const clock = sinon.useFakeTimers();
const fixture = document.querySelector('#qunit-fixture');
const vid = document.createElement('video');

fixture.appendChild(vid);

const player = videojs(vid);

player.src(sourceOne);

clock.tick(1);

// Declaring the spies here avoids listening to the changes that took place when loading the source.
const handleTechSourceset_ = sinon.spy(player, 'handleTechSourceset_');
const techGet_ = sinon.spy(player, 'techGet_');
const updateSourceCaches_ = sinon.spy(player, 'updateSourceCaches_');

player.tech_.trigger('sourceset');

assert.ok(handleTechSourceset_.calledOnce, 'handleTechSourceset_ was called');
assert.ok(!techGet_.called, 'techGet_ was not called');
assert.ok(updateSourceCaches_.calledOnce, 'updateSourceCaches_ was called');
assert.equal(player.cache_.src, '', 'player.cache_.src was reset');

player.tech_.trigger('loadstart');

assert.ok(techGet_.called, 'techGet_ was called');
assert.equal(updateSourceCaches_.callCount, 2, 'updateSourceCaches_ was called twice');

handleTechSourceset_.restore();
techGet_.restore();
updateSourceCaches_.restore();
player.dispose();
});
});

0 comments on commit cf39dee

Please sign in to comment.