Due to the Flash security model, this demo must be run from a web server<br />
From 5 to 40 seconds, the footnote 'The video is "RiP: A Remix Manifesto", by Brett Gaylor' will appear below 'Footnote Area'.
<hr >
- Vimeo does not support their player to be chromeless (hidden controls), but custsom controls have been developed and tied into their player.<br />
+ Youtube does not support their player to be chromeless (hidden controls), but custsom controls have been developed and tied into their player.<br />
Clicking play/pause or seeking in either the video or via custsom controls will cause the other to update.<br />
Clicking on the embed option in the Vimeo player while the video is playing will cause the video to pause and custom controls to update.<br />
- The vimeo video can be specified in the HTML source by giving the vimeo web site url (http://vimeo.com/VIDEOID) to either the VimeoEngine or as the iframe src attribute.<br/>
+ The video can be specified in the HTML source by giving the vimeo web site url (http://www.youtube.com/watch?v=VIDEOID) to either Popcorn.youtube or as the div src attribute.<br/>
</p>
<br />
<br />
var matches = url.match( /((http:\/\/)?www\.)?youtube\.[a-z]+\/watch\?v\=[a-z0-9]+/i );
+ if ( !matches ) {
+ return;
+ }
+
// Return id, which comes after first equals sign
- return !matches || matches[0].split( "=" )[1];
+ return matches[0].split( "=" )[1];
};
// Extract the id from a player url
var matches = url.match( /^http:\/\/?www\.youtube\.[a-z]+\/e\/[a-z0-9]+/i );
+ if ( !matches ) {
+ return;
+ }
+
// Return id, which comes after first equals sign
- return !matches || matches[0].split( "/e/" )[1];
+ return matches[0].split( "/e/" )[1];
};
function cueDelayedDurationCheck ( evt ) {
var self = this,
container = document.getElementById( elementId ),
+ src,
durEvtType;
-
- if ( !container ) {
- throw "Container ID could not be found";
- }
- // The video id for youtube (web or player formats)
- this.vidId = extractIdFromUrl( url ) || extractIdFromUri( url );
-
- if ( !this.vidId ) {
- throw "Must supply a video url!";
- }
-
- this.playerId = Popcorn.guid( elementId );
+ this.playerId = elementId;
this.readyState = READY_STATE_HAVE_NOTHING;
this.eventListeners = {};
this.loadStarted = false;
this.previousVolume = 0;
this.duration = Number.MAX_VALUE;
- this.addEventListener( "load", function() {
- self.video.cueVideoByUrl( getPlayerAddress( self.vidId ) );
- cueDelayedDurationCheck.call( self, "playing" );
- });
+ // The video id for youtube (web or player formats)
+ this.vidId = extractIdFromUrl( url ) || extractIdFromUri( url );
+
+ var loadByctor = !!this.vidId;
- this.video = createSWFObject({
- playerId: this.playerId,
- videoId: this.vidId,
- width: container.getAttribute("width") || 460,
- height: container.getAttribute("height") || 350
- });
+ // Container not yet loaded, load it on DOMDontentLoad
+ if ( container ) {
+ this.vidId = this.vidId || extractIdFromUrl( container.getAttribute( "src" ) ) || extractIdFromUri( container.getAttribute( "src" ) );
+
+ if ( !this.vidId ) {
+ throw "Could not find video id";
+ }
+
+ if ( container.children.length ) {
+ this.video = container.firstChild;
+ } else {
+ this.video = createSWFObject({
+ playerId: this.playerId,
+ videoId: this.vidId,
+ width: container.getAttribute("width") || 460,
+ height: container.getAttribute("height") || 350
+ });
+
+ container.appendChild( this.video );
+ }
+ } else {
+ document.addEventListener( "DOMContentLoaded", function() {
+ container = document.getElementById( elementId );
+
+ if ( !container ) {
+ throw "Could not find container!";
+ }
+
+ self.vidId = self.vidId || extractIdFromUrl( container.getAttribute( "src" ) ) || extractIdFromUri( container.getAttribute( "src" ) );
+
+ if ( !self.vidId ) {
+ throw "Could not find video id";
+ }
+
+ self.video = createSWFObject({
+ playerId: self.playerId,
+ videoId: self.vidId,
+ width: container.getAttribute("width") || 460,
+ height: container.getAttribute("height") || 350
+ });
+
+ container.appendChild( self.video );
+ }, false);
+ }
- container.appendChild( this.video );
+ if ( loadByctor ) {
+ this.addEventListener( "load", function() {
+ self.video.cueVideoByUrl( getPlayerAddress( self.vidId ) );
+ cueDelayedDurationCheck.call( self, "playing" );
+ });
+ }
registry[this.playerId] = this;
QUnit.reset();
+ // events must be fired in this order
+ var expectedEvents = [
+ 'play',
+ 'loadeddata',
+ 'volumechange',
+ 'playing',
+ 'volumechange',
+ 'pause',
+ 'play',
+ 'playing',
+ 'seeked',
+ 'volumechange',
+ 'volumechange',
+ 'playing',
+ 'pause',
+ 'ended'
+ ];
+
var count = 0,
- expects = 19;
+ eventCount = 0,
+ added = [],
+ set1Executed = false,
+ set2Executed = false,
+ set3Executed = false,
+ expects = expectedEvents.length + 5;
stop( 15000 );
+ expect(expects);
popcorn.volume(1); // is muted later
ok( false, "This should not be run." );
});
- // events must be fired in this order
- var expectedEvents = [
- 'play',
- 'loadeddata',
- 'volumechange',
- 'playing',
- 'volumechange',
- 'pause',
- 'play',
- 'playing',
- 'seeked',
- 'volumechange',
- 'volumechange',
- 'playing',
- 'pause',
- 'ended'
- ];
-
- var expectedEventCount = expectedEvents.length;
- expect(expectedEventCount + 5);
-
+
// register each events
- var eventCount = 0;
- var added = [];
for ( var i in expectedEvents ) {
(function( event ) {
// skip same listeners already added
}
// operations set1
- var set1Executed = false;
popcorn.listen( 'playing', function() {
// prevent double calling
if ( set1Executed ) {
popcorn.play();
// operations set2
- var set2Executed = false;
popcorn.listen( 'pause', function() {
if ( set2Executed ) {
return;
});
// operations set3
- var set3Executed = false;
popcorn.listen( 'seeked', function() {
if ( set3Executed ) {
return;
equals( rawTube.duration, Number.MAX_VALUE, 'Duration starts as Max Value');
plus();
- rawTube.addEventListener( "playing", function() {
+ rawTube.addEventListener( "durationchange", function() {
notEqual( rawTube.duration, Number.MAX_VALUE, "Duration has been changed from max value" );
plus();
notEqual( rawTube.duration, 0, "Duration is non-zero" );