Skip to content

Commit

Permalink
fix: sourceset and browser behavior inconsistencies (#5054)
Browse files Browse the repository at this point in the history
  * We now trigger `sourceset` any time a `<source>` element is appended to a mediaEl with no source.
  * `load` should always fire a `sourceset`
  * `sourceset` should always be the absolute url.
  • Loading branch information
brandonocasey committed May 9, 2018
1 parent 72f84d5 commit 3609e10
Show file tree
Hide file tree
Showing 5 changed files with 190 additions and 192 deletions.
4 changes: 3 additions & 1 deletion src/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -2621,9 +2621,11 @@ class Player extends Component {

if (!titleCaseEquals(sourceTech.tech, this.techName_)) {
this.changingSrc_ = true;

// load this technology with the chosen source
this.loadTech_(sourceTech.tech, sourceTech.source);
this.tech_.ready(() => {
this.changingSrc_ = false;
});
return false;
}

Expand Down
12 changes: 8 additions & 4 deletions src/js/tech/html5.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ class Html5 extends Tech {
constructor(options, ready) {
super(options, ready);

if (options.enableSourceset) {
this.setupSourcesetHandling_();
}

const source = options.source;
let crossoriginTracks = false;

Expand All @@ -52,6 +48,11 @@ class Html5 extends Tech {
this.handleLateInit_(this.el_);
}

// setup sourceset after late sourceset/init
if (options.enableSourceset) {
this.setupSourcesetHandling_();
}

if (this.el_.hasChildNodes()) {

const nodes = this.el_.childNodes;
Expand Down Expand Up @@ -117,6 +118,9 @@ class Html5 extends Tech {
* Dispose of `HTML5` media element and remove all tracks.
*/
dispose() {
if (this.el_.resetSourceset_) {
this.el_.resetSourceset_();
}
Html5.disposeMediaElement(this.el_);
this.options_ = null;

Expand Down
Loading

0 comments on commit 3609e10

Please sign in to comment.