| author | hamidouk |
| Mon, 10 Oct 2011 16:40:37 +0200 | |
| branch | popcorn-port |
| changeset 58 | f92e6c4baae9 |
| parent 55 | a5440e1a18a8 |
| child 62 | aa30f4339117 |
| permissions | -rw-r--r-- |
|
51
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
1 |
var jwplayerObjects = {}; |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
2 |
|
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
3 |
Popcorn.player( "jwplayer", { |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
4 |
_setup: function( options ) { |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
5 |
|
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
6 |
var media = this, |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
7 |
player = {}, |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
8 |
container = document.createElement( "div" ), |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
9 |
currentTime = 0, |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
10 |
seekTime = 0, |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
11 |
seeking = false, |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
12 |
dataLoaded = false; |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
13 |
container.id = media.id + Popcorn.guid(); |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
14 |
|
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
15 |
media.appendChild( container ); |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
16 |
|
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
17 |
var initApi = function () { |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
18 |
jwplayer( container.id ).onTime(function() { |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
19 |
currentTime = jwplayer(container.id).getPosition(); |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
20 |
media.dispatchEvent( "timeupdate" ); |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
21 |
// timeout = setTimeout( timeupdate, 10 ); |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
22 |
}); |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
23 |
|
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
24 |
media.play = function() { |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
25 |
media.paused = false; |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
26 |
media.dispatchEvent( "play" ); |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
27 |
if ( dataLoaded ) { |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
28 |
media.dispatchEvent( "loadeddata" ); |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
29 |
dataLoaded = false; |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
30 |
} |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
31 |
|
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
32 |
media.dispatchEvent( "playing" ); |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
33 |
jwplayer( container.id ).play(); |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
34 |
}; |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
35 |
|
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
36 |
media.pause = function() { |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
37 |
|
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
38 |
if ( !media.paused ) { |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
39 |
media.paused = true; |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
40 |
media.dispatchEvent( "pause" ); |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
41 |
jwplayer( container.id ).pause(); |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
42 |
} |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
43 |
}; |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
44 |
|
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
45 |
Popcorn.player.defineProperty( media, "currentTime", { |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
46 |
set: function( val ) { |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
47 |
// make sure val is a number |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
48 |
currentTime = seekTime = +val; |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
49 |
seeking = true; |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
50 |
media.dispatchEvent( "seeked" ); |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
51 |
media.dispatchEvent( "timeupdate" ); |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
52 |
jwplayer( container.id ).seek( currentTime ); |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
53 |
return currentTime; |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
54 |
}, |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
55 |
get: function() { |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
56 |
return jwplayer( container.id ).getPosition(); |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
57 |
} |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
58 |
}); |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
59 |
|
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
60 |
Popcorn.player.defineProperty( media, "muted", { |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
61 |
set: function( val ) { |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
62 |
if ( jwplayer( container.id ).getMute() !== val ) { |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
63 |
if ( val ) { |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
64 |
jwplayer( container.id ).setMute(true); |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
65 |
} else { |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
66 |
jwplayer( container.id ).setMute(false); |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
67 |
} |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
68 |
|
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
69 |
media.dispatchEvent( "volumechange" ); |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
70 |
} |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
71 |
|
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
72 |
return jwplayer( container.id ).getMute(); |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
73 |
}, |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
74 |
get: function() { |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
75 |
return jwplayer( container.id ).getMute(); |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
76 |
} |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
77 |
}); |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
78 |
|
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
79 |
Popcorn.player.defineProperty( media, "volume", { |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
80 |
|
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
81 |
set: function( val ) { |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
82 |
|
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
83 |
if ( jwplayer( container.id ).getVolume() !== val *100 ) { |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
84 |
jwplayer( container.id ).setVolume( val * 100); |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
85 |
media.dispatchEvent( "volumechange" ); |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
86 |
} |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
87 |
|
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
88 |
return (jwplayer( container.id ).getVolume()) / 100; |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
89 |
}, |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
90 |
|
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
91 |
get: function() { |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
92 |
return jwplayer( container.id ).getVolume() / 100; |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
93 |
} |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
94 |
}); |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
95 |
|
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
96 |
media.readyState = 4; |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
97 |
media.dispatchEvent( 'load' ); |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
98 |
dataLoaded = true; |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
99 |
|
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
100 |
media.duration = options.duration; |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
101 |
media.dispatchEvent( 'durationchange' ); |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
102 |
|
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
103 |
media.paused && media.dispatchEvent( 'loadeddata' ); |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
104 |
|
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
105 |
}; |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
106 |
|
| 54 | 107 |
options.events = { |
|
55
a5440e1a18a8
A bunch of changes to make the code use popcorn. Bumped the version of jwplayer
hamidouk
parents:
54
diff
changeset
|
108 |
onReady: initApi, |
|
a5440e1a18a8
A bunch of changes to make the code use popcorn. Bumped the version of jwplayer
hamidouk
parents:
54
diff
changeset
|
109 |
}; |
|
a5440e1a18a8
A bunch of changes to make the code use popcorn. Bumped the version of jwplayer
hamidouk
parents:
54
diff
changeset
|
110 |
|
| 54 | 111 |
jwplayer( container.id ).setup(options); |
|
51
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
112 |
|
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
113 |
} |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
114 |
}); |
|
1444edeae73f
Adding required popcorn files. Also changed the build file to include those
hamidouk
parents:
diff
changeset
|
115 |