Skip to content
This repository has been archived by the owner on Jun 29, 2018. It is now read-only.

Removed dependency on deprecated Youtube data API v2. #441

Merged
merged 2 commits into from
Jun 5, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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