| author | veltr |
| Mon, 17 Sep 2012 00:17:06 +0900 | |
| branch | players-as-widgets |
| changeset 957 | 4da0a5740b6c |
| parent 924 | 64c2eaafe5e2 |
| child 958 | 2aa7fdb0762a |
| permissions | -rw-r--r-- |
| 957 | 1 |
//TODO: Remove and replace by Player Widget |
2 |
||
|
711
323205a7bd39
separated jwplayer code from pop.js and put it into its own folder, players/.
hamidouk
parents:
diff
changeset
|
3 |
/* To wrap a player the develop should create a new class derived from |
|
323205a7bd39
separated jwplayer code from pop.js and put it into its own folder, players/.
hamidouk
parents:
diff
changeset
|
4 |
the IriSP.PopcornReplacement.player and defining the correct functions */ |
|
323205a7bd39
separated jwplayer code from pop.js and put it into its own folder, players/.
hamidouk
parents:
diff
changeset
|
5 |
|
|
323205a7bd39
separated jwplayer code from pop.js and put it into its own folder, players/.
hamidouk
parents:
diff
changeset
|
6 |
/** jwplayer player wrapper */ |
|
323205a7bd39
separated jwplayer code from pop.js and put it into its own folder, players/.
hamidouk
parents:
diff
changeset
|
7 |
IriSP.PopcornReplacement.jwplayer = function(container, options) { |
| 914 | 8 |
/* appel du parent pour initialiser les structures communes à tous les players */ |
9 |
IriSP.PopcornReplacement.player.call(this, container, options); |
|
| 924 | 10 |
|
11 |
if (options.autostart) { |
|
12 |
this.media.paused = false; |
|
13 |
this.trigger("play"); |
|
14 |
} |
|
| 914 | 15 |
|
| 919 | 16 |
var _player = jwplayer(this.container), |
| 924 | 17 |
_this = this, |
18 |
_seekPause = false; |
|
|
711
323205a7bd39
separated jwplayer code from pop.js and put it into its own folder, players/.
hamidouk
parents:
diff
changeset
|
19 |
|
|
323205a7bd39
separated jwplayer code from pop.js and put it into its own folder, players/.
hamidouk
parents:
diff
changeset
|
20 |
/* Définition des fonctions de l'API - */ |
| 914 | 21 |
this.playerFns = { |
| 919 | 22 |
play: function() { return _player.play(true); }, |
23 |
pause: function() { return _player.pause(true); }, |
|
| 914 | 24 |
getPosition: function() { return _player.getPosition(); }, |
| 924 | 25 |
seek: function(pos) { |
26 |
_seekPause = _this.media.paused; |
|
27 |
return _player.seek(pos); |
|
28 |
}, |
|
| 914 | 29 |
getMute: function() { return _player.getMute() }, |
30 |
setMute: function(p) { return _player.setMute(p); }, |
|
31 |
getVolume: function() { return _player.getVolume() / 100; }, |
|
32 |
setVolume: function(p) { return _player.setVolume(Math.floor(100*p)); } |
|
33 |
} |
|
|
711
323205a7bd39
separated jwplayer code from pop.js and put it into its own folder, players/.
hamidouk
parents:
diff
changeset
|
34 |
|
| 919 | 35 |
options.events = { |
36 |
onReady: function() { |
|
37 |
_this.trigger("loadedmetadata"); |
|
38 |
}, |
|
39 |
onTime: function() { |
|
| 924 | 40 |
if (_seekPause) { |
41 |
_player.pause(true); |
|
42 |
_seekPause = false; |
|
43 |
} else { |
|
44 |
if (_this.media.paused && _player.getState() === "PLAYING") { |
|
45 |
_this.media.paused = false; |
|
46 |
_this.trigger("play"); |
|
47 |
} |
|
| 923 | 48 |
} |
| 919 | 49 |
_this.trigger("timeupdate"); |
50 |
}, |
|
51 |
onPlay: function() { |
|
| 924 | 52 |
if (!_seekPause) { |
53 |
_this.media.paused = false; |
|
54 |
_this.trigger("play"); |
|
55 |
} |
|
| 919 | 56 |
}, |
57 |
onPause: function() { |
|
| 923 | 58 |
_this.media.paused = true; |
| 919 | 59 |
_this.trigger("pause"); |
60 |
}, |
|
61 |
onSeek: function() { |
|
62 |
_this.trigger("seeked"); |
|
63 |
} |
|
64 |
}; |
|
|
711
323205a7bd39
separated jwplayer code from pop.js and put it into its own folder, players/.
hamidouk
parents:
diff
changeset
|
65 |
|
| 914 | 66 |
_player.setup(options); |
|
711
323205a7bd39
separated jwplayer code from pop.js and put it into its own folder, players/.
hamidouk
parents:
diff
changeset
|
67 |
}; |
|
323205a7bd39
separated jwplayer code from pop.js and put it into its own folder, players/.
hamidouk
parents:
diff
changeset
|
68 |
|
|
323205a7bd39
separated jwplayer code from pop.js and put it into its own folder, players/.
hamidouk
parents:
diff
changeset
|
69 |
IriSP.PopcornReplacement.jwplayer.prototype = new IriSP.PopcornReplacement.player("", {}); |