Skip to content
This repository has been archived by the owner on Jun 29, 2018. It is now read-only.

Fix Bug 1037584 - Changes from #890556 breaks player unit test #403

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
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
62 changes: 24 additions & 38 deletions modules/player/popcorn.player.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,45 +393,31 @@
// Default to using HTML5 video. Similar to the HTMLVideoElement
// wrapper, we put a video in the div passed to us via:
// Popcorn.smart( div, src, options )
var videoHTML,
videoElement,
videoID = Popcorn.guid( "popcorn-video-" ),
videoHTMLContainer = document.createElement( "div" );

videoHTMLContainer.style.width = "100%";
videoHTMLContainer.style.height = "100%";

// If we only have one source, do not bother with source elements.
// This means we don't have the IE9 hack,
// and we can properly listen to error events.
// That way an error event can be told to backup to Flash if it fails.
if ( src.length === 1 ) {
videoElement = document.createElement( "video" );
videoElement.id = videoID;
node.appendChild( videoElement );
setTimeout( function() {
// Hack to decode html characters like & to &
var decodeDiv = document.createElement( "div" );
decodeDiv.innerHTML = src[ 0 ];

videoElement.src = decodeDiv.firstChild.nodeValue;
}, 0 );
return Popcorn( '#' + videoID, options );
}

node.appendChild( videoHTMLContainer );
// IE9 doesn't like dynamic creation of source elements on <video>
// so we do it in one shot via innerHTML.
videoHTML = '<video id="' + videoID + '" preload=auto autobuffer>';
for ( i = 0, srcLength = src.length; i < srcLength; i++ ) {
videoHTML += '<source src="' + src[ i ] + '">';
}
videoHTML += "</video>";
videoHTMLContainer.innerHTML = videoHTML;
var videoElement,
videoID = Popcorn.guid( "popcorn-video-" );

videoElement = document.createElement( "video" );
videoElement.id = videoID;
node.appendChild( videoElement );
setTimeout( function() {
function decodeSrc( source ) {
// Hack to decode html characters like &amp; to &
var decodeDiv = document.createElement( "div" );
decodeDiv.innerHTML = source;
return decodeDiv.firstChild.nodeValue;
}

if ( options && options.events && options.events.error ) {
node.addEventListener( "error", options.events.error, false );
}
// If we only have one source, do not bother with source elements.
if ( src.length === 1 ) {
videoElement.src = decodeSrc( src[ 0 ] );
} else {
for ( var i = 0, srcLength = src.length; i < srcLength; i++ ) {
var source = document.createElement( "source" );
source.src = decodeSrc( src[ i ] );
videoElement.appendChild( source );
}
}
}, 0 );
return Popcorn( '#' + videoID, options );
};
})( Popcorn );