Skip to content

Commit

Permalink
fix: let the tech preload auto on its own (#4861) (#5065)
Browse files Browse the repository at this point in the history
This was found due to the work done in #4660. Basically we reload the video element twice on every source with preload set to auto. This can potentially cause the same data to be downloaded twice.
  • Loading branch information
brandonocasey authored Apr 3, 2018
1 parent e2b9d58 commit c04dac4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
6 changes: 1 addition & 5 deletions src/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -2501,6 +2501,7 @@ class Player extends Component {
}

// wait until the tech is ready to set the source
// and set it synchronously if possible (#2326)
this.ready(function() {

// The setSource tech method was added with source handlers
Expand All @@ -2513,11 +2514,6 @@ class Player extends Component {
this.techCall_('src', source.src);
}

if (this.options_.preload === 'auto') {
this.load();
}

// Set the source synchronously if possible (#2326)
}, true);

return false;
Expand Down
6 changes: 2 additions & 4 deletions test/unit/sourceset.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ QUnit[qunitFn]('sourceset', function(hooks) {
});
});

// TODO: unskip when https://github.com/videojs/video.js/pull/4861 is merged
QUnit.skip('data-setup preload auto', function(assert) {
QUnit.test('data-setup preload auto', function(assert) {
const done = assert.async();

this.mediaEl.setAttribute('data-setup', JSON.stringify({sources: [this.testSrc]}));
Expand Down Expand Up @@ -176,8 +175,7 @@ QUnit[qunitFn]('sourceset', function(hooks) {
this.player.src(this.testSrc);
});

// TODO: unskip when https://github.com/videojs/video.js/pull/4861 is merged
QUnit.skip('player.src({...}) preload auto', function(assert) {
QUnit.test('player.src({...}) preload auto', function(assert) {
const done = assert.async();

this.mediaEl.setAttribute('preload', 'auto');
Expand Down

0 comments on commit c04dac4

Please sign in to comment.