Skip to content

Commit

Permalink
[#945814] Time changes properly after source changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
ScottDowne committed Dec 16, 2013
1 parent e98d4cd commit 45ec42f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
8 changes: 6 additions & 2 deletions wrappers/youtube/popcorn.HTMLYouTubeVideoElement.js
Expand Up @@ -102,7 +102,7 @@
self._util.type = "YouTube";

function addMediaReadyCallback( callback ) {
mediaReadyCallbacks.unshift( callback );
mediaReadyCallbacks.push( callback );
}

function onPlayerReady( event ) {
Expand Down Expand Up @@ -279,14 +279,18 @@
if( !( playerReady && player ) ) {
return;
}
onPause();
durationReady = false;
mediaReady = false;
firstPlay = false;
loopedPlay = false;
impl.currentTime = 0;
mediaReadyCallbacks = [];
clearInterval( currentTimeInterval );
clearInterval( bufferedInterval );
player.stopVideo();
player.clearVideo();
player.destroy();
mediaReadyCallbacks = [];
elem = document.createElement( "div" );
}

Expand Down
10 changes: 8 additions & 2 deletions wrappers/youtube/popcorn.HTMLYouTubeVideoElement.unit.js
Expand Up @@ -99,16 +99,22 @@ var testData = {
}
});

asyncTest( "YouTube 06 - source changes", 2, function() {
asyncTest( "YouTube 06 - source changes", 3, function() {

var video = testData.createMedia( "#video" );

video.addEventListener( "loadedmetadata", function loadedmetadata() {
ok( true, "first source ready event is fired" );
video.removeEventListener( "loadedmetadata", loadedmetadata, false );
video.addEventListener( "loadedmetadata", function() {
video.pause();
ok( true, "second source ready event is fired" );
start();
video.addEventListener( "play", function() {
equal( video.currentTime, 2, "times change properly after source changes" );
start();
}, false );
video.currentTime = 2;
video.play();
}, false );
video.src = "http://www.youtube.com/watch?v=HMnyrTe-j6U&autoplay=1&loop=1";
}, false );
Expand Down

0 comments on commit 45ec42f

Please sign in to comment.