From b593789d93ea73b44c095ad8372cc1f246dc87a7 Mon Sep 17 00:00:00 2001 From: scottdowne Date: Tue, 10 Dec 2013 17:10:53 -0500 Subject: [PATCH] [#945814] Time changes properly after source changes. --- wrappers/youtube/popcorn.HTMLYouTubeVideoElement.js | 8 ++++++-- .../youtube/popcorn.HTMLYouTubeVideoElement.unit.js | 10 ++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/wrappers/youtube/popcorn.HTMLYouTubeVideoElement.js b/wrappers/youtube/popcorn.HTMLYouTubeVideoElement.js index 786170a0d..070f448b3 100644 --- a/wrappers/youtube/popcorn.HTMLYouTubeVideoElement.js +++ b/wrappers/youtube/popcorn.HTMLYouTubeVideoElement.js @@ -102,7 +102,7 @@ self._util.type = "YouTube"; function addMediaReadyCallback( callback ) { - mediaReadyCallbacks.unshift( callback ); + mediaReadyCallbacks.push( callback ); } function onPlayerReady( event ) { @@ -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" ); } diff --git a/wrappers/youtube/popcorn.HTMLYouTubeVideoElement.unit.js b/wrappers/youtube/popcorn.HTMLYouTubeVideoElement.unit.js index 79469f514..cfaafc445 100644 --- a/wrappers/youtube/popcorn.HTMLYouTubeVideoElement.unit.js +++ b/wrappers/youtube/popcorn.HTMLYouTubeVideoElement.unit.js @@ -99,7 +99,7 @@ var testData = { } }); - asyncTest( "YouTube 06 - source changes", 2, function() { + asyncTest( "YouTube 06 - source changes", 3, function() { var video = testData.createMedia( "#video" ); @@ -107,8 +107,14 @@ var testData = { 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 );