-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathcuepoint.coffee
More file actions
50 lines (37 loc) · 1.05 KB
/
cuepoint.coffee
File metadata and controls
50 lines (37 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#Cuepoint Coffee. A library for HTML5 Video Subtitles
class Utils
log: (@args) ->
console.log Array.prototype.slice.call this, arguments if window.console
class Cuepoint extends Utils
constructor: ->
@nativeKeys = Object.keys
init: (@slides) ->
#We need a reference to the basic elements we're using
@subtitles = document.getElementById "subtitles"
@video = document.getElementById "video"
for key, value of slides
this.addSlide key, value
this.events.call
events: ->
#Make cue point links if needed. Reqires underscore.js.
currentTime: ->
@video.currentTime
update: (@html) ->
@subtitles.innerHTML = @html
toString: (@html) ->
setTime: (@time) ->
@video.currentTime = time
@video.play()
addSlide: (@time, @html) ->
self = this
@video.addEventListener "timeupdate", ->
if this.currentTime >= time and this.currentTime <= time + 0.3
self.update html
, false
play: ->
@video.play()
pause: ->
if not @video.paused
@video.pause()
utils = new Utils
window.cuepoint = new Cuepoint