Commit daed2f46 by Bridger Maxwell

Captions now play from the Amara API. All videos show the same caption though.

parent 788321be
...@@ -17,7 +17,8 @@ class @VideoCaption ...@@ -17,7 +17,8 @@ class @VideoCaption
.bind('DOMMouseScroll', @onMovement) .bind('DOMMouseScroll', @onMovement)
captionURL: -> captionURL: ->
"/static/subs/#{@youtubeId}.srt.sjson" "http://www.universalsubtitles.org/api/1.0/subtitles/?video_url=http://www.youtube.com/watch?v=69rDtSpshAw"
# "/static/subs/#{@youtubeId}.srt.sjson"
render: -> render: ->
@$('.video-wrapper').after """ @$('.video-wrapper').after """
...@@ -30,15 +31,24 @@ class @VideoCaption ...@@ -30,15 +31,24 @@ class @VideoCaption
@fetchCaption() @fetchCaption()
fetchCaption: -> fetchCaption: ->
$.getWithPrefix @captionURL(), (captions) => $.ajax
@captions = captions.text dataType: 'jsonp'
@start = captions.start url: @captionURL()
success: (captions) =>
if onTouchBasedDevice() # We take the captions that are each in a dictionary with a key,
$('.subtitles li').html "Caption will be displayed when you start playing the video." # and create two arrays. One with all the start times, and one with
else # all the texts. Their indices correspond.
@renderCaption() @captions = []
@start = []
record = (single_caption) =>
@captions.push single_caption.text
@start.push single_caption.start_time * 1000
record single_caption for single_caption in captions
if onTouchBasedDevice()
$('.subtitles li').html "Caption will be displayed when you start playing the video."
else
@renderCaption()
renderCaption: -> renderCaption: ->
container = $('<ol>') container = $('<ol>')
...@@ -59,7 +69,7 @@ class @VideoCaption ...@@ -59,7 +69,7 @@ class @VideoCaption
search: (time) -> search: (time) ->
min = 0 min = 0
max = @start.length - 1 max = @start.length - 1
while min < max while min < max
index = Math.ceil((max + min) / 2) index = Math.ceil((max + min) / 2)
if time < @start[index] if time < @start[index]
......
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