1 /* wrapper that simulates popcorn.js because |
1 /* wrapper that simulates popcorn.js because |
2 popcorn is a bit unstable at the time */ |
2 popcorn is a bit unstable at the time */ |
|
3 |
|
4 Popcorn = {}; |
|
5 Popcorn.listen = function(msg, callback) { |
|
6 IriSP.jQuery(Popcorn).bind(msg, callback); |
|
7 }; |
|
8 |
|
9 Popcorn.trigger = function(msg, params) { |
|
10 IriSP.jQuery(msg, params); |
|
11 }; |
|
12 |
|
13 Popcorn.guid = function(prefix) { |
|
14 var str = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { |
|
15 var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8); |
|
16 return v.toString(16); |
|
17 }); |
|
18 |
|
19 return prefix + str; |
|
20 }; |
|
21 |
|
22 Popcorn.__initApi = function() { |
|
23 Popcorn.trigger("timeupdate"); |
|
24 }; |
|
25 |
|
26 Popcorn.jwplayer = function(container, options) { |
|
27 Popcorn._container = container; |
|
28 options.events = { |
|
29 onReady: Popcorn.__initApi |
|
30 }; |
|
31 |
|
32 jwplayer(Popcorn._container).setup(options); |
|
33 |
|
34 }; |
|
35 |
|
36 Popcorn.currentTime = function(time) { |
|
37 if (typeof(time) === "undefined") { |
|
38 return jwplayer(Popcorn._container).getPosition(); |
|
39 } else { |
|
40 var currentTime = +time; |
|
41 media.dispatchEvent( "seeked" ); |
|
42 media.dispatchEvent( "timeupdate" ); |
|
43 jwplayer( Popcorn._container ).seek( currentTime ); |
|
44 return jwplayer(Popcorn._container).getPosition(); |
|
45 } |
|
46 }; |
|
47 |
|
48 Popcorn.play = function() { |
|
49 Popcorn.paused = false; |
|
50 Popcorn.trigger("play"); |
|
51 Popcorn.trigger("playing"); |
|
52 jwplayer( Popcorn._container ).play(); |
|
53 }; |
|
54 |
|
55 Popcorn.pause = function() { |
|
56 if ( !media.paused ) { |
|
57 media.paused = true; |
|
58 Popcorn.trigger( "pause" ); |
|
59 jwplayer( Popcorn._container ).pause(); |
|
60 } |
|
61 }; |
|
62 |
|
63 Popcorn.muted = function(val) { |
|
64 if (typeof(val) !== "undefined") { |
|
65 if ( jwplayer( Popcorn._container ).getMute() !== val ) { |
|
66 if ( val ) { |
|
67 jwplayer( Popcorn._container ).setMute(true); |
|
68 } else { |
|
69 jwplayer( Popcorn._container ).setMute(false); |
|
70 } |
|
71 |
|
72 media.dispatchEvent( "volumechange" ); |
|
73 } |
|
74 |
|
75 return jwplayer( Popcorn._container ).getMute(); |
|
76 } else { |
|
77 return jwplayer( Popcorn._container ).getMute(); |
|
78 } |
|
79 }); |
|
80 |
|
81 |