| author | veltr |
| Tue, 26 Jun 2012 14:22:29 +0200 | |
| branch | new-model |
| changeset 919 | 972099304059 |
| parent 917 | eb8677d3a663 |
| child 957 | 4da0a5740b6c |
| permissions | -rw-r--r-- |
| 387 | 1 |
/* wrapper that simulates popcorn.js because |
2 |
popcorn is a bit unstable at the time */ |
|
| 388 | 3 |
|
| 919 | 4 |
/* Popcorn.code replacement has been disabled. It didn't work properly and was not even used */ |
5 |
||
| 702 | 6 |
IriSP.PopcornReplacement = { |
| 442 | 7 |
}; |
| 390 | 8 |
|
| 702 | 9 |
/** base class for our popcorn-compatible players. |
| 699 | 10 |
*/ |
| 702 | 11 |
IriSP.PopcornReplacement.player = function(container, options) { |
| 919 | 12 |
|
13 |
this.media = { |
|
14 |
"paused": true, |
|
15 |
"muted": false |
|
16 |
}; |
|
|
870
2c025db10a10
Migrated playerWidget and started annotationsListWidget
veltr
parents:
841
diff
changeset
|
17 |
|
| 919 | 18 |
this.container = container.replace(/^#/,''); //remove '#' at beginning |
19 |
this.msgPump = {}; /* dictionnary used to receive and send messages */ |
|
20 |
this._options = options; |
|
| 917 | 21 |
|
| 388 | 22 |
}; |
23 |
||
| 699 | 24 |
IriSP.PopcornReplacement.player.prototype.listen = function(msg, callback) { |
| 919 | 25 |
if (!this.msgPump.hasOwnProperty(msg)) { |
26 |
this.msgPump[msg] = []; |
|
27 |
} |
|
28 |
this.msgPump[msg].push(callback); |
|
| 699 | 29 |
}; |
30 |
||
| 917 | 31 |
IriSP.PopcornReplacement.player.prototype.on = IriSP.PopcornReplacement.player.prototype.listen; |
32 |
||
| 699 | 33 |
IriSP.PopcornReplacement.player.prototype.trigger = function(msg, params) { |
| 919 | 34 |
if (!this.msgPump.hasOwnProperty(msg)) { |
35 |
return; |
|
36 |
} |
|
37 |
var d = this.msgPump[msg]; |
|
38 |
for(var i = 0; i < d.length; i++) { |
|
39 |
d[i].call(window, params); |
|
40 |
} |
|
| 388 | 41 |
}; |
42 |
||
| 917 | 43 |
IriSP.PopcornReplacement.player.prototype.emit = IriSP.PopcornReplacement.player.prototype.trigger; |
| 919 | 44 |
/* |
| 702 | 45 |
IriSP.PopcornReplacement.player.prototype.guid = function(prefix) { |
| 388 | 46 |
var str = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { |
47 |
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8); |
|
48 |
return v.toString(16); |
|
49 |
}); |
|
50 |
||
51 |
return prefix + str; |
|
52 |
}; |
|
53 |
||
| 702 | 54 |
/** init the api after that flash player has been setup - called by the callback |
55 |
defined by the embedded flash player |
|
| 919 | 56 |
|
| 702 | 57 |
IriSP.PopcornReplacement.player.prototype.__initApi = function() { |
58 |
this.trigger("loadedmetadata"); // we've done more than loading metadata of course, |
|
|
463
7ef123b2410f
trigger a bunch of signals for popcorn compatibility.
hamidouk
parents:
458
diff
changeset
|
59 |
// but popcorn doesn't need to know more. |
| 702 | 60 |
this.media.muted = this.playerFns.getMute(); |
| 919 | 61 |
/* some programmed segments are supposed to be run at the beginning |
| 578 | 62 |
var i = 0; |
| 702 | 63 |
for(i = 0; i < this.__codes.length; i++) { |
64 |
var c = this.__codes[i]; |
|
| 578 | 65 |
if (0 == c.start) { |
66 |
c.onStart(); |
|
67 |
} |
|
68 |
|
|
69 |
if (0 == c.end) { |
|
70 |
c.onEnd(); |
|
71 |
} |
|
72 |
} |
|
| 919 | 73 |
|
| 388 | 74 |
}; |
| 919 | 75 |
*/ |
| 388 | 76 |
|
| 702 | 77 |
IriSP.PopcornReplacement.player.prototype.currentTime = function(time) { |
|
605
e1a6f73038b4
made the listWidget redraw at every timeupdate event (added a small optimization though,
hamidouk
parents:
604
diff
changeset
|
78 |
if (typeof(time) === "undefined") { |
| 702 | 79 |
return this.playerFns.getPosition(); |
| 388 | 80 |
} else { |
81 |
var currentTime = +time; |
|
| 723 | 82 |
this.playerFns.seek(currentTime); |
| 604 | 83 |
return currentTime; |
| 388 | 84 |
} |
85 |
}; |
|
86 |
||
| 702 | 87 |
IriSP.PopcornReplacement.player.prototype.play = function() { |
88 |
this.media.paused = false; |
|
89 |
this.trigger("play"); |
|
90 |
this.playerFns.play(); |
|
| 388 | 91 |
}; |
92 |
|
|
| 702 | 93 |
IriSP.PopcornReplacement.player.prototype.pause = function() { |
94 |
this.media.paused = true; |
|
| 919 | 95 |
this.trigger("pause"); |
| 702 | 96 |
this.playerFns.pause(); |
| 390 | 97 |
}; |
98 |
||
| 702 | 99 |
IriSP.PopcornReplacement.player.prototype.muted = function(val) { |
100 |
if (typeof(val) !== "undefined") { |
|
101 |
||
102 |
if (this.playerFns.getMute() !== val) { |
|
103 |
if (val) { |
|
104 |
this.playerFns.setMute(true); |
|
105 |
this.media.muted = true; |
|
106 |
} else { |
|
107 |
this.playerFns.setMute(false); |
|
108 |
this.media.muted = false; |
|
109 |
} |
|
| 394 | 110 |
|
| 702 | 111 |
this.trigger( "volumechange" ); |
112 |
} |
|
113 |
|
|
114 |
return this.playerFns.getMute(); |
|
115 |
} else { |
|
116 |
return this.playerFns.getMute(); |
|
117 |
} |
|
118 |
}; |
|
119 |
||
| 839 | 120 |
IriSP.PopcornReplacement.player.prototype.volume = function(val) { |
121 |
if (typeof this.playerFns.getVolume == "undefined" || typeof this.playerFns.setVolume == "undefined") { |
|
122 |
return false; |
|
123 |
} |
|
124 |
var _vol = this.playerFns.getVolume(); |
|
125 |
if (typeof(val) !== "undefined" && parseFloat(val) !== NaN) { |
|
126 |
val = Math.max(0, Math.min(1, val)); |
|
127 |
if (parseFloat(val) != parseFloat(_vol)) { |
|
128 |
this.playerFns.setVolume(val); |
|
129 |
this.trigger("volumechange"); |
|
130 |
_vol = this.playerFns.getVolume(); |
|
131 |
} |
|
132 |
} |
|
133 |
return _vol; |
|
134 |
}; |
|
135 |
||
| 917 | 136 |
IriSP.PopcornReplacement.player.prototype.mute = function() { |
137 |
this.muted(true); |
|
138 |
} |
|
139 |
||
140 |
IriSP.PopcornReplacement.player.prototype.unmute = function() { |
|
141 |
this.muted(false); |
|
142 |
} |
|
| 702 | 143 |
|
|
441
99b7c5192330
fixed horrible bug involving jQuery message passing.
hamidouk
parents:
431
diff
changeset
|
144 |
|
| 702 | 145 |
IriSP.PopcornReplacement.player.prototype.roundTime = function() { |
146 |
var currentTime = this.currentTime(); |
|
| 394 | 147 |
return Math.round(currentTime); |
|
711
323205a7bd39
separated jwplayer code from pop.js and put it into its own folder, players/.
hamidouk
parents:
706
diff
changeset
|
148 |
}; |