Commit 754be2ca by Valera Rozuvan

If Video Alpha is playing a YouTube video in Firefox in HTML5 mode, then when…

If Video Alpha is playing a YouTube video in Firefox in HTML5 mode, then when switching to speed 1.0 it will simply reload the iframe, instead of using the built-in method to change the speed. The fixes the bug temporarily, while the YouTube team fixes the bug internally in the API. Commented additions to fix YouTube firefox speed 1.0 switch bug.
parent 9e0997d3
...@@ -66,7 +66,16 @@ class @VideoPlayerAlpha extends SubviewAlpha ...@@ -66,7 +66,16 @@ class @VideoPlayerAlpha extends SubviewAlpha
if @video.end if @video.end
# work in AS3, not HMLT5. but iframe use AS3 # work in AS3, not HMLT5. but iframe use AS3
@playerVars.end = @video.end @playerVars.end = @video.end
# There is a bug which prevents YouTube API to correctly set the speed to 1.0 from another speed
# in Firefox when in HTML5 mode. There is a fix which basically reloads the video at speed 1.0
# when this change is requested (instead of simply requesting a speed change to 1.0). This has to
# be done only when the video is being watched in Firefox. We need to figure out what browser is
# currently executing this code.
@video.isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1
if @video.videoType is 'html5' if @video.videoType is 'html5'
@video.playerType = 'browser'
@player = new HTML5Video.Player @video.el, @player = new HTML5Video.Player @video.el,
playerVars: @playerVars, playerVars: @playerVars,
videoSources: @video.html5Sources, videoSources: @video.html5Sources,
...@@ -79,6 +88,7 @@ class @VideoPlayerAlpha extends SubviewAlpha ...@@ -79,6 +88,7 @@ class @VideoPlayerAlpha extends SubviewAlpha
youTubeId = @video.videos['1.0'] youTubeId = @video.videos['1.0']
else else
youTubeId = @video.youtubeId() youTubeId = @video.youtubeId()
@video.playerType = 'youtube'
@player = new YT.Player @video.id, @player = new YT.Player @video.id,
playerVars: @playerVars playerVars: @playerVars
videoId: youTubeId videoId: youTubeId
...@@ -235,13 +245,18 @@ class @VideoPlayerAlpha extends SubviewAlpha ...@@ -235,13 +245,18 @@ class @VideoPlayerAlpha extends SubviewAlpha
if @video.videoType is 'youtube' if @video.videoType is 'youtube'
if @video.show_captions is true if @video.show_captions is true
@caption.currentSpeed = newSpeed @caption.currentSpeed = newSpeed
if @video.videoType is 'html5'
@player.setPlaybackRate newSpeed # We request the reloading of the video in the case when YouTube is in Flash player mode,
else if @video.videoType is 'youtube' # or when we are in Firefox, and the new speed is 1.0. The second case is necessary to
# avoid the bug where in Firefox speed switching to 1.0 in HTML5 player mode is handled
# incorrectly by YouTube API.
if (@video.videoType is 'youtube') or ((@video.isFirefox) and (@video.playerType is 'youtube') and (newSpeed is '1.0'))
if @isPlaying() if @isPlaying()
@player.loadVideoById(@video.youtubeId(), @currentTime) @player.loadVideoById(@video.youtubeId(), @currentTime)
else else
@player.cueVideoById(@video.youtubeId(), @currentTime) @player.cueVideoById(@video.youtubeId(), @currentTime)
else if @video.videoType is 'html5'
@player.setPlaybackRate newSpeed
if @video.videoType is 'youtube' if @video.videoType is 'youtube'
@updatePlayTime @currentTime @updatePlayTime @currentTime
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment