|
957
|
1 |
//TODO: Remove and replace by Player Widget |
|
|
2 |
|
|
894
|
3 |
/* To wrap a player the develop should create a new class derived from |
|
|
4 |
the IriSP.PopcornReplacement.player and defining the correct functions */ |
|
|
5 |
|
|
|
6 |
/** jwplayer player wrapper */ |
|
|
7 |
IriSP.PopcornReplacement.mashup = function(container, options) { |
|
|
8 |
/* Appel du constructeur de la classe parente */ |
|
|
9 |
IriSP.PopcornReplacement.player.call(this, container, options); |
|
919
|
10 |
|
|
894
|
11 |
var _this = this; |
|
|
12 |
|
|
|
13 |
/* Définition des fonctions de commande : |
|
|
14 |
this.playerFns.play, .pause, .getPosition, .seek, |
|
|
15 |
.getMute, .setMute, .getVolume, .setVolume |
|
|
16 |
doivent être rattachés aux fonctions du player |
|
|
17 |
* */ |
|
|
18 |
|
|
|
19 |
this.playerFns = { |
|
|
20 |
play : function() { |
|
|
21 |
if (_this.player) { |
|
|
22 |
return _this.player.playVideo(); |
|
|
23 |
} else { |
|
|
24 |
return false; |
|
|
25 |
} |
|
|
26 |
}, |
|
|
27 |
pause : function() { |
|
|
28 |
if (_this.player) { |
|
|
29 |
return _this.player.pauseVideo(); |
|
|
30 |
} else { |
|
|
31 |
return false; |
|
|
32 |
} |
|
|
33 |
}, |
|
|
34 |
getPosition : function() { |
|
|
35 |
if (_this.player) { |
|
|
36 |
return _this.player.getCurrentTime(); |
|
|
37 |
} else { |
|
|
38 |
return 0; |
|
|
39 |
} |
|
|
40 |
}, |
|
|
41 |
seek : function(pos) { |
|
|
42 |
if (_this.player) { |
|
|
43 |
return _this.player.seekTo(pos); |
|
|
44 |
} else { |
|
|
45 |
return false; |
|
|
46 |
} |
|
|
47 |
}, |
|
|
48 |
getMute : function() { |
|
|
49 |
if (_this.player) { |
|
|
50 |
return _this.player.isMuted(); |
|
|
51 |
} else { |
|
|
52 |
return false; |
|
|
53 |
} |
|
|
54 |
}, |
|
|
55 |
setMute : function(p) { |
|
|
56 |
if (_this.player) { |
|
|
57 |
if (p) { |
|
|
58 |
_this.player.mute(); |
|
|
59 |
} |
|
|
60 |
else { |
|
|
61 |
_this.player.unMute(); |
|
|
62 |
} |
|
|
63 |
} |
|
|
64 |
}, |
|
|
65 |
getVolume : function() { |
|
|
66 |
if (_this.player) { |
|
|
67 |
return _this.player.getVolume() / 2; |
|
|
68 |
} else { |
|
|
69 |
return false; |
|
|
70 |
} |
|
|
71 |
}, |
|
|
72 |
setVolume : function(p) { |
|
|
73 |
if (_this.player) { |
|
|
74 |
_this.player.setVolume(Math.floor(2 * p)); |
|
|
75 |
} |
|
|
76 |
}, |
|
|
77 |
} |
|
|
78 |
|
|
|
79 |
/* Dailymotion utilise un système de fonctions référencées dans |
|
|
80 |
* des variables globales pour la gestion des événements. |
|
|
81 |
*/ |
|
|
82 |
|
|
|
83 |
window.onBabPlayerReady = function() { |
|
|
84 |
_this.onReady(); |
|
|
85 |
}; |
|
|
86 |
window.onBabStateChange = function(_state) { |
|
|
87 |
_this.onStateChange(_state); |
|
|
88 |
} |
|
|
89 |
window.onBabVideoProgress = function(_progress) { |
|
|
90 |
_this.onProgress(_progress); |
|
|
91 |
} |
|
|
92 |
|
|
|
93 |
var params = { |
|
|
94 |
allowScriptAccess : "always", |
|
|
95 |
wmode: "transparent", |
|
|
96 |
quality: "high", |
|
|
97 |
menu: true, |
|
|
98 |
bgcolor: "#869ca7" |
|
|
99 |
}; |
|
|
100 |
var atts = { |
|
|
101 |
id : this.container |
|
|
102 |
}; |
|
|
103 |
var flashvars = { |
|
|
104 |
urlData: options.mashup_xml |
|
|
105 |
}; |
|
|
106 |
swfobject.embedSWF(options.mashup_swf, this.container, options.width, options.height, "8", null, flashvars, params, atts); |
|
|
107 |
|
|
|
108 |
}; |
|
|
109 |
|
|
|
110 |
IriSP.PopcornReplacement.mashup.prototype = new IriSP.PopcornReplacement.player("", {}); |
|
|
111 |
|
|
|
112 |
IriSP.PopcornReplacement.mashup.prototype.onReady = function() { |
|
|
113 |
this.player = document.getElementById(this.container); |
|
919
|
114 |
this.trigger("loadedmetadata"); |
|
894
|
115 |
}; |
|
|
116 |
|
|
|
117 |
IriSP.PopcornReplacement.mashup.prototype.onProgress = function(progressInfo) { |
|
919
|
118 |
this.trigger("timeupdate"); |
|
894
|
119 |
} |
|
|
120 |
|
|
|
121 |
IriSP.PopcornReplacement.mashup.prototype.onStateChange = function(state) { |
|
919
|
122 |
|
|
894
|
123 |
switch(state) { |
|
|
124 |
case 1: |
|
919
|
125 |
this.trigger("play"); |
|
894
|
126 |
break; |
|
|
127 |
|
|
|
128 |
case 2: |
|
919
|
129 |
this.trigger("pause"); |
|
894
|
130 |
break; |
|
|
131 |
|
|
|
132 |
case 3: |
|
919
|
133 |
this.trigger("seeked"); |
|
894
|
134 |
break; |
|
|
135 |
} |
|
919
|
136 |
|
|
894
|
137 |
}; |