Skip to content

Commit

Permalink
Merge pull request mozilla#441 from pculture/master
Browse files Browse the repository at this point in the history
Removed dependency on deprecated Youtube data API v2.
  • Loading branch information
ScottDowne committed Jun 5, 2015
2 parents 076087c + 8c632b4 commit 8ae202a
Showing 1 changed file with 19 additions and 30 deletions.
49 changes: 19 additions & 30 deletions wrappers/youtube/popcorn.HTMLYouTubeVideoElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,11 @@

function onBuffering() {
impl.networkState = self.NETWORK_LOADING;
var newDuration = player.getDuration();
if (impl.duration !== newDuration) {
impl.duration = newDuration;
self.dispatchEvent( "durationchange" );
}
self.dispatchEvent( "waiting" );
}

Expand Down Expand Up @@ -406,38 +411,22 @@
// Get video ID out of youtube url
aSrc = regexYouTube.exec( aSrc )[ 1 ];

var xhrURL = "https://gdata.youtube.com/feeds/api/videos/" + aSrc + "?v=2&alt=jsonc&callback=?";
// Get duration value.
Popcorn.getJSONP( xhrURL, function( resp ) {

var warning = "failed to retreive duration data, reason: ";
if ( resp.error ) {
console.warn( warning + resp.error.message );
return ;
} else if ( !resp.data ) {
console.warn( warning + "no response data" );
return;
player = new YT.Player( elem, {
width: "100%",
height: "100%",
wmode: playerVars.wmode,
videoId: aSrc,
playerVars: playerVars,
events: {
'onReady': onPlayerReady,
'onError': onPlayerError,
'onStateChange': onPlayerStateChange
}
impl.duration = resp.data.duration;
self.dispatchEvent( "durationchange" );

player = new YT.Player( elem, {
width: "100%",
height: "100%",
wmode: playerVars.wmode,
videoId: aSrc,
playerVars: playerVars,
events: {
'onReady': onPlayerReady,
'onError': onPlayerError,
'onStateChange': onPlayerStateChange
}
});

impl.networkState = self.NETWORK_LOADING;
self.dispatchEvent( "loadstart" );
self.dispatchEvent( "progress" );
});

impl.networkState = self.NETWORK_LOADING;
self.dispatchEvent( "loadstart" );
self.dispatchEvent( "progress" );
}

function monitorCurrentTime() {
Expand Down

0 comments on commit 8ae202a

Please sign in to comment.