Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Make sure to maintain errors on source tags after initialization #1575

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/js/media/html5.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@ vjs.Html5 = vjs.MediaTechController.extend({

var source = options['source'];

// set the source if one was provided
if (source && this.el_.currentSrc !== source.src) {
// Set the source if one is provided
// 1) Check if the source is new (if not, we want to keep the original so playback isn't interrupted)
// 2) Check to see if the network state of the tag was failed at init, and if so, reset the source
// anyway so the error gets fired.
if ((source && this.el_.currentSrc !== source.src) || (player.tag && player.tag.initNetworkState_ === 3)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any way source could be undefined but player.tag.initNetworkState_ === 3? That doesn't seem possible but we still may want to check for source in the second part of this.

this.el_.src = source.src;
}

Expand Down
4 changes: 4 additions & 0 deletions src/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,10 @@ vjs.Player.prototype.createEl = function(){
this.width(this.options_['width'], true); // (true) Skip resize listener on load
this.height(this.options_['height'], true);

// vjs.insertFirst seems to cause the networkState to flicker from 3 to 2, so
// keep track of the original for later so we can know if the source originally failed
tag.initNetworkState_ = tag.networkState;

// Wrap video tag in div (el/box) container
if (tag.parentNode) {
tag.parentNode.insertBefore(el, tag);
Expand Down