Skip to content

Commit

Permalink
Changing video tag src attributes will fail in IE9 if source elements…
Browse files Browse the repository at this point in the history
… are present. It will always play the first source even if you set this.el.src. We must remove the source elements before trying to change the src attribtue programatically.
  • Loading branch information
onyxrev committed Oct 19, 2012
1 parent 489025c commit e26aa1b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
5 changes: 0 additions & 5 deletions src/resolutions.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ _V_.merge(_V_.Player.prototype, {
// remember our position in the current stream
var curTime = this.currentTime();

// unloading the tech might 'technically' (hehe) be unnecessary
// but ensures that we don't have residual mess from the last
// playback
this.unloadTech();

// reload the new tech and the new source (mostly used to re-fire
// the events we want)
this.loadTech(this.techName, {src: new_source.src});
Expand Down
13 changes: 13 additions & 0 deletions tech/html5/html5.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ _V_.html5 = _V_.PlaybackTech.extend({
this.triggerReady();
},

removeSources: function(el){
var srcs = el.getElementsByTagName("source");

for(var i=0;i<srcs.length;i++){
el.removeChild(srcs[i]);
}
},

destroy: function(){
this.player.tag = false;
this.removeTriggers();
Expand Down Expand Up @@ -77,6 +85,11 @@ _V_.html5 = _V_.PlaybackTech.extend({
}
}, this);

// IE9 prefers the source elements, if present, over programatic
// attempts attempts to change the video src attribute. IE9 will
// fail to swap sources unless we remove the source elements. we
// have already parsed the relevant data out of them anyway.
this.removeSources(el);
return el;
},

Expand Down

0 comments on commit e26aa1b

Please sign in to comment.