From: ScottDowne Date: Mon, 21 Mar 2011 15:47:26 +0000 (-0400) Subject: [#408] google scripts need to wait for google.load X-Git-Tag: v0.4.1~2^2~1 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=b91f7674e7ea0efdd9aeb1ea8f387170cb89e162;p=popcorn-js.git [#408] google scripts need to wait for google.load --- diff --git a/demos/semantic_video/index.html b/demos/semantic_video/index.html index 2144b95..aa7c243 100644 --- a/demos/semantic_video/index.html +++ b/demos/semantic_video/index.html @@ -4,10 +4,6 @@ HTML5 Video Demo Using popcorn.js - - - - @@ -22,7 +18,6 @@ - diff --git a/plugins/googlenews/popcorn.googlenews.js b/plugins/googlenews/popcorn.googlenews.js index b0cfdf7..8cb509c 100644 --- a/plugins/googlenews/popcorn.googlenews.js +++ b/plugins/googlenews/popcorn.googlenews.js @@ -1,11 +1,23 @@ // PLUGIN: Google News (function (Popcorn) { - var scriptLoaded = false; - Popcorn.getScript( "http://www.google.com/jsapi", function() { - google.load("elements", "1", {packages : ["newsshow"], callback: function() {scriptLoaded = true;}}); - }); + var scriptLoaded = false, + callBack = function( data ) { + + if ( typeof google !== 'undefined' && google.load ) { + + google.load("elements", "1", {packages : ["newsshow"], callback: function() {scriptLoaded = true;}}); + } else { + + setTimeout( function() { + + callBack( data ); + }, 1); + } + } + + Popcorn.getScript( "http://www.google.com/jsapi", callBack ); /** * Google News popcorn plug-in diff --git a/plugins/subtitle/popcorn.subtitle.js b/plugins/subtitle/popcorn.subtitle.js index 454f8e3..8c266d6 100644 --- a/plugins/subtitle/popcorn.subtitle.js +++ b/plugins/subtitle/popcorn.subtitle.js @@ -2,11 +2,22 @@ (function (Popcorn) { - var scriptLoaded = false; + var scriptLoaded = false, + callBack = function( data ) { - Popcorn.getScript( "http://www.google.com/jsapi", function() { - google.load("language", "1", {callback: function() {scriptLoaded = true;}}); - }); + if ( typeof google !== 'undefined' && google.load ) { + + google.load("language", "1", {callback: function() {scriptLoaded = true;}}); + } else { + + setTimeout( function() { + + callBack( data ); + }, 1); + } + } + + Popcorn.getScript( "http://www.google.com/jsapi", callBack ); /** * Subtitle popcorn plug-in