Skip to content

Commit

Permalink
Merge branch 'develop' of git://github.com/cadecairos/popcorn-js into…
Browse files Browse the repository at this point in the history
… 1.0

* 'develop' of git://github.com/cadecairos/popcorn-js: (28 commits)
  Fixed my fail when I merged #776 [#802]
  Seek to end of video before testing Compose to make independent
  [#792] fixed twitter tests running in opera
  [#704] grammar fix in comment. Sorry, no tests for the grammar fix.
  fixed never ending frame animation looping after an instance is destroyed [#800]
  Fixed leaking exec calls in Index Integrity tests [#800]
  added tests for triggered events
  Adde functionality to remove a plugins manifest when removePlugin is called. Also added supporting tests
  [#793] webpage plugin no longer needs http://
  [#792] twitter has plain text search now, and tests
  [704] updated comment to be more accurate
  [#704] teardown calls end before calling teardown
  [t534] Better documentation
  [#543] null fix
  [#795] youtube now fires a canplaythrough event
  [#791] default empty subtitle is now empty string
  Moved 'refresh' into a private function so it's no longer exposed on the global Popcorn object
  triggers canplaythrough
  added 7 flashvar parameters available as options
  [#543] Function inlining
  ...
  • Loading branch information
rwaldron committed Nov 1, 2011
2 parents dadf920 + a5d5db2 commit fb5c0a8
Show file tree
Hide file tree
Showing 26 changed files with 498 additions and 71 deletions.
2 changes: 1 addition & 1 deletion parsers/parserTTML/popcorn.parserTTML.js
Expand Up @@ -102,7 +102,7 @@

// Trim left and right whitespace from text and change non-explicit line breaks to spaces
sub.text = node.textContent.replace(/^[\s]+|[\s]+$/gm, "").replace(/(?:\r\n|\r|\n)/gm, "<br />");
sub.id = node.getAttribute( "xml:id" );
sub.id = node.getAttribute( "xml:id" ) || node.getAttribute( "id" );
sub.start = toSeconds ( node.getAttribute( "begin" ), timeOffset );
sub.end = toSeconds( node.getAttribute( "end" ), timeOffset );
sub.target = region;
Expand Down
10 changes: 6 additions & 4 deletions players/vimeo/popcorn.vimeo.js
Expand Up @@ -203,6 +203,7 @@
});

media.readyState = 4;
media.dispatchEvent( "canplaythrough" );
media.dispatchEvent( "load" );
media.duration = vimeoObject.api_getDuration();
media.dispatchEvent( "durationchange" );
Expand Down Expand Up @@ -231,12 +232,13 @@

flashvars = {
clip_id: src,
show_portrait: 1,
show_byline: 1,
show_title: 1,
js_api: 1,
js_swf_id: vimeoContainer.id
js_swf_id: vimeoContainer.id,
};

// extend options from user to flashvars. NOTE: Videos owned by Plus Vimeo users may override these options
Popcorn.extend( flashvars, options );

params = {
allowscriptaccess: "always",
allowfullscreen: "true",
Expand Down
1 change: 1 addition & 0 deletions players/vimeo/popcorn.vimeo.unit.html
Expand Up @@ -4,6 +4,7 @@
<title>Vimeo Player Unit Test Suite</title>
<link rel="stylesheet" href="../../test/qunit/qunit.css" type="text/css" media="screen">
<script src="../../test/qunit/qunit.js"></script>
<script src="../../test/jquery.js"></script>
<!--
do not move - this must be called immediately prior to
popcorn-api-draft.js
Expand Down
61 changes: 59 additions & 2 deletions players/vimeo/popcorn.vimeo.unit.js
@@ -1,9 +1,42 @@
test( "Options Check", function() {
QUnit.reset();
expect( 7 );
var varz = {
title: 0,
byline: 0,
portrait:0,
autoplay:1,
loop:1,
color: "FFAADD",
fullscreen: 0
},
p2 = Popcorn.vimeo( "#player_1", "http://player.vimeo.com/video/6960892", varz );

stop();

p2.listen( "loadeddata", function() {
var flashvars = $( 'param[name="flashvars"]' ).attr( "value" );

var splitvars = flashvars.split( "&" );

for ( var i = 0, len = splitvars.length; i < len; i++ ) {
var item = splitvars[ i ].split( "=" );
if ( varz.hasOwnProperty( item[ 0 ] ) ) {
equal( varz[ item[ 0 ] ], item[ 1 ], item[ 0 ] + " is the expected value" );
}
}

start();
});

});

test( "Update Timer", function() {

QUnit.reset();

var p2 = Popcorn.vimeo( "#player_1", "http://player.vimeo.com/video/6960892" ),
expects = 12,
expects = 16,
count = 0,
execCount = 0,
// These make sure events are only fired once
Expand All @@ -29,6 +62,30 @@ test( "Update Timer", function() {
// These tests come close to 10 seconds on chrome, increasing to 15
stop();

p2.listen( "canplaythrough", function() {
p2.unlisten( "canplaythrough" );
ok( true, "'canplaythrough' fired" );
plus();
});

p2.listen( "load", function() {
p2.unlisten( "load" );
ok( true, "'load' fired" );
plus();
});

p2.listen( "durationchange", function() {
p2.unlisten( "durationchange" );
ok( true, "'durationchange' fired" );
plus();
});

p2.listen( "loadeddata", function() {
p2.unlisten( "loadeddata" );
ok( true, "'loadeddata' fired" );
plus();
});

Popcorn.plugin( "forwards", function() {
return {
start: function( event, options ) {
Expand Down Expand Up @@ -192,7 +249,7 @@ test( "Plugin Factory", function() {
}

expect( expects );
stop( 15000 );
stop( 20000 );

Popcorn.plugin( "executor", function() {

Expand Down
18 changes: 9 additions & 9 deletions players/youtube/popcorn.youtube.js
Expand Up @@ -29,7 +29,8 @@ Popcorn.player( "youtube", {
var flashvars,
params,
attributes,
src;
src,
query;

// expose a callback to this scope, that is called from the global callback youtube calls
onYouTubePlayerReady[ container.id ] = function() {
Expand Down Expand Up @@ -175,6 +176,7 @@ Popcorn.player( "youtube", {
});

media.readyState = 4;
media.dispatchEvent( "canplaythrough" );
media.dispatchEvent( "load" );
media.duration = youtubeObject.getDuration();
media.dispatchEvent( "durationchange" );
Expand All @@ -187,9 +189,7 @@ Popcorn.player( "youtube", {
options.annotations = +options.annotations === 1 || +options.annotations === 3 ? options.annotations : 1;

flashvars = {
playerapiid: container.id,
controls: options.controls,
iv_load_policy: options.annotations
playerapiid: container.id
};

params = {
Expand All @@ -201,16 +201,16 @@ Popcorn.player( "youtube", {
id: container.id
};

src = /^.*[\/=](.{11})/.exec( media.src )[ 1 ];
src = /^.*(?:\/|v=)(.{11})/.exec( media.src )[ 1 ];
query = ( media.src.split( "?" )[ 1 ] || "" ).replace( /v=.{11}/, "" );

swfobject.embedSWF( "http://www.youtube.com/e/" + src + "?enablejsapi=1&playerapiid=" + container.id + "&version=3",
container.id, media.offsetWidth, media.offsetHeight, "8", null,
flashvars, params, attributes );
swfobject.embedSWF( "//www.youtube.com/e/" + src + "?" + query + "&enablejsapi=1&playerapiid=" + container.id + "&version=3",
container.id, media.offsetWidth, media.offsetHeight, "8", null, flashvars, params, attributes );
};

if ( !window.swfobject ) {

Popcorn.getScript( "http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js", youtubeInit );
Popcorn.getScript( "//ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js", youtubeInit );
} else {

youtubeInit();
Expand Down
22 changes: 11 additions & 11 deletions players/youtube/popcorn.youtube.unit.js
Expand Up @@ -385,25 +385,25 @@ test( "Controls and Annotations toggling", function() {

var popcorn = Popcorn.youtube( "#video", "http://www.youtube.com/watch?v=9oar9glUCL0" ),
targetDiv = document.getElementById( "video" );
testTarget = targetDiv.querySelector( "object" ).querySelector( "param[name=flashvars]" );
testTarget = targetDiv.querySelector( "object" ).data;

ok( /controls=1/.test( testTarget.value ), "controls are defaulted to 1 ( displayed )" );
ok( /iv_load_policy=1/.test( testTarget.value ), "annotations ( iv_load_policy ) are defaulted to ( enabled )" );
ok( !/controls/.test( testTarget ), "controls are defaulted to 1 ( displayed )" );
ok( !/iv_load_policy/.test( testTarget ), "annotations ( iv_load_policy ) are defaulted to ( enabled )" );

targetDiv.innerHTML = "";

popcorn = Popcorn.youtube( "#video", "http://www.youtube.com/watch?v=9oar9glUCL0", { controls: 1, annotations: 1 } );
popcorn = Popcorn.youtube( "#video", "http://www.youtube.com/watch?v=9oar9glUCL0&controls=1&iv_load_policy=1" );

testTarget = targetDiv.querySelector( "object" ).querySelector( "param[name=flashvars]" );
ok( /controls=1/.test( testTarget.value ), "controls is set to 1 ( displayed )" );
ok( /iv_load_policy=1/.test( testTarget.value ), "annotations ( iv_load_policy ) is set to 1 ( enabled )" );
testTarget = targetDiv.querySelector( "object" ).data;
ok( /controls=1/.test( testTarget ), "controls is set to 1 ( displayed )" );
ok( /iv_load_policy=1/.test( testTarget ), "annotations ( iv_load_policy ) is set to 1 ( enabled )" );

targetDiv.innerHTML = "";

popcorn = Popcorn.youtube( "#video", "http://www.youtube.com/watch?v=9oar9glUCL0", { controls: 0, annotations: 3 } );
testTarget = targetDiv.querySelector( "object" ).querySelector( "param[name=flashvars]" );
ok( /controls=0/.test( testTarget.value ), "controls is set to 0 ( hidden )" );
ok( /iv_load_policy=3/.test( testTarget.value ), "annotations ( iv_load_policy ) is set to 3 ( hidden )" );
popcorn = Popcorn.youtube( "#video", "http://www.youtube.com/watch?v=9oar9glUCL0&controls=0&iv_load_policy=3" );
testTarget = targetDiv.querySelector( "object" ).data;
ok( /controls=0/.test( testTarget ), "controls is set to 0 ( hidden )" );
ok( /iv_load_policy=3/.test( testTarget ), "annotations ( iv_load_policy ) is set to 3 ( hidden )" );

});

2 changes: 1 addition & 1 deletion plugins/facebook/popcorn.facebook.js
Expand Up @@ -182,7 +182,7 @@
if ( !ranOnce || options.event_app_id ) {
ranOnce = true;
// initialize facebook JS SDK
Popcorn.getScript( "http://connect.facebook.net/en_US/all.js" );
Popcorn.getScript( "//connect.facebook.net/en_US/all.js" );

global.fbAsyncInit = function() {
FB.init({
Expand Down
4 changes: 2 additions & 2 deletions plugins/gml/popcorn.gml.js
Expand Up @@ -163,7 +163,7 @@
target && target.appendChild( options.container );

var scriptReady = function() {
Popcorn.getJSONP( "http://000000book.com/data/" + options.gmltag + ".json?callback=", function( data ) {
Popcorn.getJSONP( "//000000book.com/data/" + options.gmltag + ".json?callback=", function( data ) {

options.pjsInstance = new Processing( options.container, gmlPlayer );
options.pjsInstance.construct( self.media, data, options );
Expand All @@ -173,7 +173,7 @@

if ( !window.Processing ) {

Popcorn.getScript( "http://processingjs.org/content/download/processing-js-1.3.0/processing-1.3.0.min.js", scriptReady );
Popcorn.getScript( "//processingjs.org/content/download/processing-js-1.3.0/processing-1.3.0.min.js", scriptReady );
} else {

scriptReady();
Expand Down
4 changes: 2 additions & 2 deletions plugins/googlefeed/popcorn.googlefeed.js
Expand Up @@ -11,7 +11,7 @@
len = links.length,
head = document.head || document.getElementsByTagName( "head" )[ 0 ],
css = document.createElement( "link" ),
resource = "http://www.google.com/uds/solutions/dynamicfeed/gfdynamicfeedcontrol.";
resource = "//www.google.com/uds/solutions/dynamicfeed/gfdynamicfeedcontrol.";

if ( !window.GFdynamicFeedControl ) {

Expand Down Expand Up @@ -40,7 +40,7 @@

if ( !window.google ) {

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

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

Expand Down
2 changes: 1 addition & 1 deletion plugins/googlemap/popcorn.googlemap.js
Expand Up @@ -25,7 +25,7 @@ var googleCallback;
// for some reason the Google Map API adds content to the body
if ( document.body ) {
_mapFired = true;
Popcorn.getScript( "http://maps.google.com/maps/api/js?sensor=false&callback=googleCallback" );
Popcorn.getScript( "//maps.google.com/maps/api/js?sensor=false&callback=googleCallback" );
} else {
setTimeout(function () {
loadMaps();
Expand Down
2 changes: 1 addition & 1 deletion plugins/lastfm/popcorn.lastfm.js
Expand Up @@ -77,7 +77,7 @@
count: 0,
htmlString: "Unknown Artist"
};
Popcorn.getJSONP( "http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist=" + options.artist + "&api_key=" + options.apikey + "&format=json&callback=lastFMcallback", lastFMcallback, false );
Popcorn.getJSONP( "//ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist=" + options.artist + "&api_key=" + options.apikey + "&format=json&callback=lastFMcallback", lastFMcallback, false );
}
_artists[ options.artist ].count++;

Expand Down
2 changes: 1 addition & 1 deletion plugins/linkedin/popcorn.linkedin.js
Expand Up @@ -117,7 +117,7 @@
target = document.getElementById( options.target ),
script = document.createElement( "script" );

Popcorn.getScript( "http://platform.linkedin.com/in.js" );
Popcorn.getScript( "//platform.linkedin.com/in.js" );

options._container = document.createElement( "div" );
options._container.appendChild( script );
Expand Down
10 changes: 5 additions & 5 deletions plugins/openmap/popcorn.openmap.js
Expand Up @@ -87,7 +87,7 @@
location = new OpenLayers.LonLat( 0, 0 );
// query TinyGeocoder and re-center in callback
Popcorn.getJSONP(
"http://tinygeocoder.com/create-api.php?q=" + options.location + "&callback=jsonp",
"//tinygeocoder.com/create-api.php?q=" + options.location + "&callback=jsonp",
function( latlng ) {
centerlonlat = new OpenLayers.LonLat( latlng[ 1 ], latlng[ 0 ] );
options.map.setCenter( centerlonlat );
Expand All @@ -100,7 +100,7 @@
if ( options.type === "SATELLITE" ) {
// add NASA WorldWind / LANDSAT map
options.map = new OpenLayers.Map( { div: newdiv, "maxResolution": 0.28125, tileSize: new OpenLayers.Size( 512, 512 ) } );
var worldwind = new OpenLayers.Layer.WorldWind( "LANDSAT", "http://worldwind25.arc.nasa.gov/tile/tile.aspx", 2.25, 4, { T: "105" } );
var worldwind = new OpenLayers.Layer.WorldWind( "LANDSAT", "//worldwind25.arc.nasa.gov/tile/tile.aspx", 2.25, 4, { T: "105" } );
options.map.addLayer( worldwind );
displayProjection = new OpenLayers.Projection( "EPSG:4326" );
projection = new OpenLayers.Projection( "EPSG:4326" );
Expand All @@ -110,7 +110,7 @@
displayProjection = new OpenLayers.Projection( "EPSG:4326" );
projection = new OpenLayers.Projection( "EPSG:4326" );
options.map = new OpenLayers.Map( {div: newdiv, projection: projection } );
var relief = new OpenLayers.Layer.WMS( "USGS Terraserver", "http://terraserver-usa.org/ogcmap.ashx?", { layers: "DRG" } );
var relief = new OpenLayers.Layer.WMS( "USGS Terraserver", "//terraserver-usa.org/ogcmap.ashx?", { layers: "DRG" } );
options.map.addLayer( relief );
} else {
// add OpenStreetMap layer
Expand Down Expand Up @@ -139,7 +139,7 @@

// insert openlayers api script once
if ( !window.OpenLayers ) {
Popcorn.getScript( "http://openlayers.org/api/OpenLayers.js" );
Popcorn.getScript( "//openlayers.org/api/OpenLayers.js" );
}

var isReady = function() {
Expand Down Expand Up @@ -193,7 +193,7 @@
},
gcThenPlotMarker = function( myMarker ) {
Popcorn.getJSONP(
"http://tinygeocoder.com/create-api.php?q=" + myMarker.location + "&callback=jsonp",
"//tinygeocoder.com/create-api.php?q=" + myMarker.location + "&callback=jsonp",
function( latlng ) {
var myPoint = new OpenLayers.Geometry.Point( latlng[1], latlng[0] ).transform( displayProjection, projection ),
myPointStyle = OpenLayers.Util.extend( {}, layerStyle );
Expand Down
2 changes: 1 addition & 1 deletion plugins/processing/popcorn.processing.js
Expand Up @@ -74,7 +74,7 @@
}

if ( !window.Processing ) {
Popcorn.getScript( "http://processingjs.org/content/download/processing-js-1.3.0/processing-1.3.0.js", function() {
Popcorn.getScript( "//processingjs.org/content/download/processing-js-1.3.0/processing-1.3.0.js", function() {
scriptReady( options );
});
} else {
Expand Down
2 changes: 1 addition & 1 deletion plugins/subtitle/popcorn.subtitle.js
Expand Up @@ -107,7 +107,7 @@
options.innerContainer = newdiv;

options.showSubtitle = function() {
options.innerContainer.innerHTML = options.text;
options.innerContainer.innerHTML = options.text || "";
};
},
/**
Expand Down
1 change: 1 addition & 0 deletions plugins/subtitle/popcorn.subtitle.unit.html
Expand Up @@ -56,5 +56,6 @@ <h2 id="qunit-userAgent"></h2>
<p>Your user agent does not support the HTML5 Video element.</p>

</video>
<div id="sub-content"></div>
</body>
</html>
29 changes: 29 additions & 0 deletions plugins/subtitle/popcorn.subtitle.unit.js
Expand Up @@ -143,3 +143,32 @@ test( "Popcorn Subtitle Plugin", function() {
plus();
});
});

test( "subtitle data tests", function() {

var popped = Popcorn( "#video" ),
expects = 1,
count = 0,
container = document.getElementById( "sub-content" );

expect( expects );

function plus() {
if ( ++count === expects ) {
start();
}
}

stop( 12000 );

popped.subtitle({
start: 0,
end: 10,
target: "sub-content"
});

popped.pause( 0 );

equals( container.children[ 0 ].innerHTML, "", "subtitle with no text defaults to an empty string" );
plus();
});

0 comments on commit fb5c0a8

Please sign in to comment.