Commit 823843cd by Prem Sichanugrist

Make sure video is working in sequence module

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