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