Work on adding native spped change for YouTube HTML5. Not complete.

This commit is contained in:
Valera Rozuvan
2013-02-01 18:02:41 +02:00
parent eff8ad6762
commit b2bffb010e
2 changed files with 29 additions and 0 deletions

View File

@@ -89,8 +89,24 @@ class @VideoPlayerAlpha extends SubviewAlpha
$('.video-load-complete:first').data('video').player.play()
onStateChange: (event) =>
_this = this
switch event.data
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]
$.each availableSpeeds, (index, value) ->
_this.video.videos[value.toFixed(2).replace(/\.00$/, ".0")] = baseSpeedSubs
@speedControl.reRender()
console.log "UNSTARTED. available speeds = "
console.log availableSpeeds
@onUnstarted()
when @PlayerState.PLAYING
@onPlay()

View File

@@ -30,6 +30,19 @@ class @VideoSpeedControlAlpha extends SubviewAlpha
@$('.video_speeds').prepend($('<li>').attr('data-speed', speed).html(link))
@setSpeed(@currentSpeed)
reRender: (newSpeeds) ->
@$('.video_speeds').empty()
@speeds newSpeeds
console.log "Changing speeds"
console.log @speeds
$.each @speeds, (index, speed) =>
link = $('<a>').attr(href: "#").html("#{speed}x")
@$('.video_speeds').prepend($('<li>').attr('data-speed', speed).html(link))
@$('.video_speeds a').click @changeVideoSpeed
changeVideoSpeed: (event) =>
event.preventDefault()
unless $(event.target).parent().hasClass('active')