forked from gdroberts/rashomon
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathpopcorn.rashomonvideo.js
63 lines (56 loc) · 1.93 KB
/
popcorn.rashomonvideo.js
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// PLUGIN: video controller for rashomon project
// inputs are 'vid' which is a rashomon video object
// and 'timeline' which is the Rashomon timeline object
(function (Popcorn) {
Popcorn.plugin( "rashomonVideo", {
manifest: {
about:{
name: "rashomon video plugin",
version: "0.1",
author: "aphid",
website: "aphid.org"
},
options:{
vid: {elem:'input', type:'object', label: 'Video'},
timeline: {elem:'input', type:'object', label: 'Timeline'},
start : {elem:'input', type:'number', label:'In'},
end : {elem:'input', type:'number', label:'Out'}
}
},
_setup: function( options ) {
},
/**
*
* The start function will be executed when the currentTime
* of the video reaches the start time provided by the
* options variable
*/
start: function( event, options ) {
if ($("#vid" + options.vid.id).hasClass("vidactive")){
var timediff = + options.timeline.currentTime() - options.vid.offset;
$("#vcontain" + options.vid.id).show("fast", "linear");
options.vid.pp.currentTime(timediff);
//options.vid.showVid();
if (!Rashomon.timeline.media.paused) {
options.vid.pp.play();
}
}
},
/**
*
* The end function will be executed when the currentTime
* of the video reaches the end time provided by the
* options variable
*/
end: function( event, options ) {
var timediff = + options.timeline.currentTime() - options.vid.offset;
console.log(timediff);
options.vid.hideVid();
if (timediff < 0) {
options.vid.pp.pause(0);
} else if (options.timeline.currentTime() > options.vid.offset) {
options.vid.pp.pause(options.vid.pp.duration());
}
}
});
})( Popcorn );