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

[#945814] Time changes properly after source changes. #364

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
8 changes: 6 additions & 2 deletions wrappers/youtube/popcorn.HTMLYouTubeVideoElement.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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