Skip to content

Commit

Permalink
Merge Popcorn.js v1.1.1 into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher De Cairos committed Dec 22, 2011
2 parents ee5d8fb + d1053a9 commit 90797af
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 138 deletions.
154 changes: 78 additions & 76 deletions players/soundcloud/popcorn.soundcloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,102 +228,104 @@
swfobject.embedSWF( "http://player.soundcloud.com/player.swf", self._playerId, self.offsetWidth, self.height, "9.0.0", "expressInstall.swf", flashvars, params, attributes );
}

Popcorn.getScript( "http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js" );

// Source file originally from 'https://github.com/soundcloud/Widget-JS-API/raw/master/soundcloud.player.api.js'
Popcorn.getScript( "http://popcornjs.org/code/players/soundcloud/lib/soundcloud.player.api.js", function() {
// Play event is fired twice when player is first started. Ignore second one
var ignorePlayEvt = 1;
Popcorn.soundcloud = function( containerId, src, options ) {

// Register the wrapper's load event with the player
soundcloud.addEventListener( 'onPlayerReady', function( object, data ) {
var wrapper = registry[object.api_getFlashId()];
Popcorn.getScript( "http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js" );

wrapper.swfObj = object;
wrapper.duration = object.api_getTrackDuration();
wrapper.currentTime = object.api_getTrackPosition();
// This eliminates volumechangee event from firing on load
wrapper.volume = wrapper.previousVolume = object.api_getVolume()/100;
// Source file originally from 'https://github.com/soundcloud/Widget-JS-API/raw/master/soundcloud.player.api.js'
Popcorn.getScript( "http://popcornjs.org/code/players/soundcloud/lib/soundcloud.player.api.js", function() {
// Play event is fired twice when player is first started. Ignore second one
var ignorePlayEvt = 1;

// The numeric id of the track for use with Soundcloud API
wrapper._mediaId = data.mediaId;
// Register the wrapper's load event with the player
soundcloud.addEventListener( 'onPlayerReady', function( object, data ) {
var wrapper = registry[object.api_getFlashId()];

wrapper.dispatchEvent( 'load' );
wrapper.dispatchEvent( 'canplay' );
wrapper.dispatchEvent( 'durationchange' );
wrapper.swfObj = object;
wrapper.duration = object.api_getTrackDuration();
wrapper.currentTime = object.api_getTrackPosition();
// This eliminates volumechangee event from firing on load
wrapper.volume = wrapper.previousVolume = object.api_getVolume()/100;

wrapper.timeupdate();
});
// The numeric id of the track for use with Soundcloud API
wrapper._mediaId = data.mediaId;

// Register events for when the flash player plays a track for the first time
soundcloud.addEventListener( 'onMediaStart', function( object, data ) {
var wrapper = registry[object.api_getFlashId()];
wrapper.played = 1;
wrapper.dispatchEvent( 'playing' );
});
wrapper.dispatchEvent( 'load' );
wrapper.dispatchEvent( 'canplay' );
wrapper.dispatchEvent( 'durationchange' );

// Register events for when the flash player plays a track
soundcloud.addEventListener( 'onMediaPlay', function( object, data ) {
if ( ignorePlayEvt ) {
ignorePlayEvt = 0;
return;
}
wrapper.timeupdate();
});

var wrapper = registry[object.api_getFlashId()];
wrapper.dispatchEvent( 'play' );
});
// Register events for when the flash player plays a track for the first time
soundcloud.addEventListener( 'onMediaStart', function( object, data ) {
var wrapper = registry[object.api_getFlashId()];
wrapper.played = 1;
wrapper.dispatchEvent( 'playing' );
});

// Register events for when the flash player pauses a track
soundcloud.addEventListener( 'onMediaPause', function( object, data ) {
var wrapper = registry[object.api_getFlashId()];
wrapper.dispatchEvent( 'pause' );
});
// Register events for when the flash player plays a track
soundcloud.addEventListener( 'onMediaPlay', function( object, data ) {
if ( ignorePlayEvt ) {
ignorePlayEvt = 0;
return;
}

// Register events for when the flash player is buffering
soundcloud.addEventListener( 'onMediaBuffering', function( object, data ) {
var wrapper = registry[object.api_getFlashId()];
var wrapper = registry[object.api_getFlashId()];
wrapper.dispatchEvent( 'play' );
});

wrapper.dispatchEvent( 'progress' );
// Register events for when the flash player pauses a track
soundcloud.addEventListener( 'onMediaPause', function( object, data ) {
var wrapper = registry[object.api_getFlashId()];
wrapper.dispatchEvent( 'pause' );
});

if ( wrapper.readyState === 0 ) {
wrapper.readyState = 3;
wrapper.dispatchEvent( "readystatechange" );
}
});
// Register events for when the flash player is buffering
soundcloud.addEventListener( 'onMediaBuffering', function( object, data ) {
var wrapper = registry[object.api_getFlashId()];

// Register events for when the flash player is done buffering
soundcloud.addEventListener( 'onMediaDoneBuffering', function( object, data ) {
var wrapper = registry[object.api_getFlashId()];
wrapper.dispatchEvent( 'canplaythrough' );
});
wrapper.dispatchEvent( 'progress' );

// Register events for when the flash player has finished playing
soundcloud.addEventListener( 'onMediaEnd', function( object, data ) {
var wrapper = registry[object.api_getFlashId()];
wrapper.paused = 1;
//wrapper.pause();
wrapper.dispatchEvent( 'ended' );
});
if ( wrapper.readyState === 0 ) {
wrapper.readyState = 3;
wrapper.dispatchEvent( "readystatechange" );
}
});

// Register events for when the flash player has seeked
soundcloud.addEventListener( 'onMediaSeek', function( object, data ) {
var wrapper = registry[object.api_getFlashId()];
// Register events for when the flash player is done buffering
soundcloud.addEventListener( 'onMediaDoneBuffering', function( object, data ) {
var wrapper = registry[object.api_getFlashId()];
wrapper.dispatchEvent( 'canplaythrough' );
});

wrapper.setCurrentTime( object.api_getTrackPosition() );
// Register events for when the flash player has finished playing
soundcloud.addEventListener( 'onMediaEnd', function( object, data ) {
var wrapper = registry[object.api_getFlashId()];
wrapper.paused = 1;
//wrapper.pause();
wrapper.dispatchEvent( 'ended' );
});

if ( wrapper.paused ) {
wrapper.dispatchEvent( "timeupdate" );
}
});
// Register events for when the flash player has seeked
soundcloud.addEventListener( 'onMediaSeek', function( object, data ) {
var wrapper = registry[object.api_getFlashId()];

// Register events for when the flash player has errored
soundcloud.addEventListener( 'onPlayerError', function( object, data ) {
var wrapper = registry[object.api_getFlashId()];
wrapper.dispatchEvent( 'error' );
wrapper.setCurrentTime( object.api_getTrackPosition() );

if ( wrapper.paused ) {
wrapper.dispatchEvent( "timeupdate" );
}
});

// Register events for when the flash player has errored
soundcloud.addEventListener( 'onPlayerError', function( object, data ) {
var wrapper = registry[object.api_getFlashId()];
wrapper.dispatchEvent( 'error' );
});
});
});

Popcorn.soundcloud = function( containerId, src, options ) {
return new Popcorn.soundcloud.init( containerId, src, options );
};

Expand Down Expand Up @@ -690,4 +692,4 @@
});
}
});
})( Popcorn, window );
})( Popcorn, window );
104 changes: 52 additions & 52 deletions plugins/googlefeed/popcorn.googlefeed.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,58 +2,7 @@
(function ( Popcorn ) {

var i = 1,
scriptLoaded = false,

dynamicFeedLoad = function() {
var dontLoad = false,
k = 0,
links = document.getElementsByTagName( "link" ),
len = links.length,
head = document.head || document.getElementsByTagName( "head" )[ 0 ],
css = document.createElement( "link" ),
resource = "//www.google.com/uds/solutions/dynamicfeed/gfdynamicfeedcontrol.";

if ( !window.GFdynamicFeedControl ) {

Popcorn.getScript( resource + "js", function() {
scriptLoaded = true;
});

} else {
scriptLoaded = true;
}

// Checking if the css file is already included
for ( ; k < len; k++ ){
if ( links[ k ].href === resource + "css" ) {
dontLoad = true;
}
}

if ( !dontLoad ) {
css.type = "text/css";
css.rel = "stylesheet";
css.href = resource + "css";
head.insertBefore( css, head.firstChild );
}
};

if ( !window.google ) {

Popcorn.getScript( "//www.google.com/jsapi", function() {

google.load( "feeds", "1", {

callback: function () {

dynamicFeedLoad();
}
});
});

} else {
dynamicFeedLoad();
}
scriptLoaded = false;

/**
* googlefeed popcorn plug-in
Expand Down Expand Up @@ -81,6 +30,57 @@

Popcorn.plugin( "googlefeed", function( options ) {

var dynamicFeedLoad = function() {
var dontLoad = false,
k = 0,
links = document.getElementsByTagName( "link" ),
len = links.length,
head = document.head || document.getElementsByTagName( "head" )[ 0 ],
css = document.createElement( "link" ),
resource = "//www.google.com/uds/solutions/dynamicfeed/gfdynamicfeedcontrol.";

if ( !window.GFdynamicFeedControl ) {

Popcorn.getScript( resource + "js", function() {
scriptLoaded = true;
});

} else {
scriptLoaded = true;
}

// Checking if the css file is already included
for ( ; k < len; k++ ){
if ( links[ k ].href === resource + "css" ) {
dontLoad = true;
}
}

if ( !dontLoad ) {
css.type = "text/css";
css.rel = "stylesheet";
css.href = resource + "css";
head.insertBefore( css, head.firstChild );
}
};

if ( !window.google ) {

Popcorn.getScript( "//www.google.com/jsapi", function() {

google.load( "feeds", "1", {

callback: function () {

dynamicFeedLoad();
}
});
});

} else {
dynamicFeedLoad();
}

// create a new div and append it to the parent div so nothing
// that already exists in the parent div gets overwritten
var newdiv = document.createElement( "div" ),
Expand Down
13 changes: 3 additions & 10 deletions plugins/timeline/popcorn.timeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,7 @@
*
*/

var i = 1,
head = document.getElementsByTagName( "head" )[ 0 ],
css = document.createElement( "link" );

css.type = "text/css";
css.rel = "stylesheet";
css.href = "//popcornjs.org/code/plugins/timeline/popcorn.timeline.css";
head.insertBefore( css, head.firstChild );
var i = 1;

Popcorn.plugin( "timeline" , function( options ) {

Expand Down Expand Up @@ -81,8 +74,8 @@
// Default to empty if not used
//options.innerHTML = options.innerHTML || "";

contentDiv.innerHTML = "<p><span id='big'>" + options.title + "</span><br />" +
"<span id='mid'>" + options.text + "</span><br />" + options.innerHTML;
contentDiv.innerHTML = "<p><span id='big' style='font-size:24px; line-height: 130%;' >" + options.title + "</span><br />" +
"<span id='mid' style='font-size: 16px;'>" + options.text + "</span><br />" + options.innerHTML;

return {

Expand Down

0 comments on commit 90797af

Please sign in to comment.