Commit 823843cd by Prem Sichanugrist

Make sure video is working in sequence module

parent b0149541
......@@ -4,12 +4,17 @@ class window.Courseware
new Calculator
new FeedbackForm
Logger.bind()
@renderModules()
@bind()
@render()
@start: ->
new Courseware
renderModules: ->
bind: ->
if $('#seq_content').length
$('#seq_content').change @render
render: ->
$('.course-content .video').each ->
id = $(this).attr('id').replace(/video_/, '')
new Video id, $(this).data('streams')
......@@ -6,6 +6,7 @@ class window.Sequence
bind: ->
$('#sequence-list a').click @goto
$('#seq_content').change @toggleArrows
buildNavigation: ->
$.each @elements, (index, item) ->
......@@ -14,7 +15,7 @@ class window.Sequence
list_item = $('<li>').append(link.append(title))
$('#sequence-list').append list_item
toggleArrows: ->
toggleArrows: =>
$('.sequence-nav-buttons a').unbind('click')
if @position == 1
......@@ -38,7 +39,7 @@ class window.Sequence
MathJax.Hub.Queue(["Typeset",MathJax.Hub])
@position = new_position
@toggleArrows()
$('#seq_content').change()
goto: (event) =>
event.preventDefault()
......
class Video
constructor: (@id, videos) ->
window.player = null
@element = $("#video_#{@id}")
@parseVideos videos
@fetchMetadata()
@parseSpeed()
$("#video_#{@id}").data('video', this)
window.onYouTubePlayerAPIReady = =>
$('.course-content .video').each ->
$(this).data('video').embed()
if YT.Player
@embed()
else
window.onYouTubePlayerAPIReady = =>
$('.course-content .video').each ->
$(this).data('video').embed()
youtubeId: (speed)->
@videos[speed || @speed]
......@@ -18,6 +21,8 @@ class Video
video = video.split(/:/)
speed = parseFloat(video[0]).toFixed(2).replace /\.00$/, '.0'
@videos[speed] = video[1]
@fetchMetadata()
@parseSpeed()
parseSpeed: ->
@setSpeed($.cookie('video_speed'))
......
......@@ -63,12 +63,14 @@ class VideoPlayer
$(@).trigger('ended')
onPlay: =>
Logger.log 'play_video', id: @currentTime, code: @player.getVideoEmbedCode()
window.player.pauseVideo() if window.player && window.player != @player
window.player = @player
unless @player.interval
@player.interval = setInterval(@update, 200)
onPause: =>
Logger.log 'pause_video', id: @currentTime, code: @player.getVideoEmbedCode()
window.player = null if window.player == @player
clearInterval(@player.interval)
@player.interval = null
......
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