Commit baf6bbe3 by Valera Rozuvan

Finalized HTML5 YouTube player inbrowser speed changes.

parent 143217d6
......@@ -25,7 +25,7 @@ class @VideoAlpha
"1.0": sub
"1.25": sub
"1.5": sub
@setSpeed($.cookie('video_speed'))
@setSpeed $.cookie('video_speed')
$("#video_#{@id}").data('video', this).addClass('video-load-complete')
if @show_captions is true
@hide_captions = $.cookie('hide_captions') == 'true'
......@@ -47,7 +47,7 @@ class @VideoAlpha
youtubeId: (speed)->
@videos[speed || @speed]
VideoAlpha::parseVideos = (videos) ->
parseVideos: (videos)->
return false if (typeof videos isnt "string") or (videos.length is 0)
@videos = {}
_this = this
......@@ -58,7 +58,7 @@ class @VideoAlpha
_this.videos[speed] = video[1]
true
VideoAlpha::parseVideoSources = (mp4Source, webmSource, oggSource) ->
parseVideoSources: (mp4Source, webmSource, oggSource)->
@html5Sources =
mp4: null
webm: null
......@@ -69,9 +69,9 @@ class @VideoAlpha
parseSpeed: ->
@speeds = ($.map @videos, (url, speed) -> speed).sort()
@setSpeed($.cookie('video_speed'))
@setSpeed $.cookie('video_speed')
VideoAlpha::setSpeed = (newSpeed) ->
setSpeed: (newSpeed)->
if @speeds.indexOf(newSpeed) isnt -1
@speed = newSpeed
$.cookie "video_speed", "" + newSpeed,
......@@ -91,7 +91,7 @@ class @VideoAlpha
getDuration: ->
@metadata[@youtubeId()].duration
VideoAlpha::log = (eventName) ->
log: (eventName)->
logInfo =
id: @id
code: @youtubeId()
......
......@@ -94,19 +94,16 @@ class @VideoPlayerAlpha extends SubviewAlpha
when @PlayerState.UNSTARTED
if @video.videoType is "youtube"
availableSpeeds = @player.getAvailablePlaybackRates()
console.log @video.videos
if availableSpeeds.length > 1
baseSpeedSubs = @video.videos["1.0"]
$.each @video.videos, (index, value) ->
delete _this.video.videos[index]
@video.speeds = []
$.each availableSpeeds, (index, value) ->
_this.video.videos[value.toFixed(2).replace(/\.00$/, ".0")] = baseSpeedSubs
@speedControl.reRender()
console.log "UNSTARTED. available speeds = "
console.log availableSpeeds
_this.video.speeds.push value.toFixed(2).replace(/\.00$/, ".0")
@speedControl.reRender @video.speeds
@video.videoType = 'html5'
@onUnstarted()
when @PlayerState.PLAYING
@onPlay()
......@@ -162,12 +159,12 @@ class @VideoPlayerAlpha extends SubviewAlpha
if @video.videoType is 'youtube'
@currentTime = Time.convert(@currentTime, parseFloat(@currentSpeed()), newSpeed)
newSpeed = parseFloat(newSpeed).toFixed(2).replace /\.00$/, '.0'
@video.setSpeed(newSpeed)
@video.setSpeed newSpeed
if @video.videoType is 'youtube'
if @video.show_captions is true
@caption.currentSpeed = newSpeed
if @video.videoType is 'html5'
@player.setSpeed(newSpeed)
@player.setPlaybackRate newSpeed
else if @video.videoType is 'youtube'
if @isPlaying()
@player.loadVideoById(@video.youtubeId(), @currentTime)
......
......@@ -24,20 +24,14 @@ class @VideoSpeedControlAlpha extends SubviewAlpha
<ol class="video_speeds"></ol>
</div>
"""
$.each @speeds, (index, speed) =>
link = $('<a>').attr(href: "#").html("#{speed}x")
@$('.video_speeds').prepend($('<li>').attr('data-speed', speed).html(link))
@setSpeed(@currentSpeed)
@setSpeed @currentSpeed
reRender: (newSpeeds) ->
@$('.video_speeds').empty()
@speeds newSpeeds
console.log "Changing speeds"
console.log @speeds
@speeds = newSpeeds
$.each @speeds, (index, speed) =>
link = $('<a>').attr(href: "#").html("#{speed}x")
@$('.video_speeds').prepend($('<li>').attr('data-speed', speed).html(link))
......
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