Skip to content

Commit

Permalink
fix: let the tech preload auto on its own (#4861)
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 and gkatsev committed Apr 2, 2018
1 parent 11b4d5d commit fdcae1b
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
Expand Up @@ -2492,6 +2492,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 @@ -2504,11 +2505,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
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 fdcae1b

Please sign in to comment.