| author | veltr |
| Mon, 17 Sep 2012 00:17:06 +0900 | |
| branch | players-as-widgets |
| changeset 957 | 4da0a5740b6c |
| parent 919 | 972099304059 |
| permissions | -rw-r--r-- |
| 957 | 1 |
//TODO: Remove and replace by Player Widget |
2 |
||
|
819
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
3 |
/* To wrap a player the develop should create a new class derived from |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
4 |
the IriSP.PopcornReplacement.player and defining the correct functions */ |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
5 |
|
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
6 |
/** allocine player wrapper */ |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
7 |
IriSP.PopcornReplacement.allocine = function(container, options) { |
| 822 | 8 |
// console.log("Calling allocine player"); |
|
819
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
9 |
/* appel du parent pour initialiser les structures communes à tous les players */ |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
10 |
IriSP.PopcornReplacement.player.call(this, container, options); |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
11 |
|
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
12 |
var _this = this; |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
13 |
|
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
14 |
/* Définition des fonctions de l'API - */ |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
15 |
|
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
16 |
this.playerFns = { |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
17 |
play : function() { |
| 841 | 18 |
return _this.apiCall("play"); |
|
819
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
19 |
}, |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
20 |
pause : function() { |
| 841 | 21 |
return _this.apiCall("pause"); |
|
819
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
22 |
}, |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
23 |
getPosition : function() { |
| 841 | 24 |
return _this.apiCall("getSeek","return") || 0; |
|
819
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
25 |
}, |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
26 |
seek : function(pos) { |
| 841 | 27 |
return _this.apiCall("seek",pos); |
|
819
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
28 |
}, |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
29 |
getMute : function() { |
| 841 | 30 |
return _this.apiCall("getMute","return"); |
|
819
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
31 |
}, |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
32 |
setMute : function(p) { |
| 841 | 33 |
return _this.apiCall("setMute", p); |
|
819
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
34 |
} |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
35 |
} |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
36 |
|
| 884 | 37 |
window.onReady = function() { |
38 |
_this.ready(); |
|
39 |
}; |
|
40 |
window.onAllocineStateChange = function(_state) { |
|
41 |
_this.stateHandler(_state) |
|
42 |
} |
|
43 |
window.onTime = function(_progress) { |
|
44 |
_this.progressHandler(_progress) |
|
45 |
}; |
|
|
819
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
46 |
|
| 842 | 47 |
var _flashVars = { |
48 |
"streamFMS" : true, |
|
49 |
"adVast" : false, |
|
50 |
"lg" : "fr_cinecast", |
|
51 |
"autoPlay" : options.autoPlay, |
|
52 |
"directVideoTitle" : "", |
|
53 |
"urlAcData" : options.urlAcData, |
|
| 866 | 54 |
"directVideoPath" : options.video, |
| 842 | 55 |
"host" : "http://allocine.fr" |
56 |
} |
|
| 822 | 57 |
|
| 842 | 58 |
if (typeof IriSP.__jsonMetadata["medias"][0].meta == "object" && typeof IriSP.__jsonMetadata["medias"][0].meta.subtitles == "string") { |
59 |
_flashVars.subTitlePath = IriSP.__jsonMetadata["medias"][0].meta.subtitles; |
|
60 |
} |
|
|
819
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
61 |
|
| 842 | 62 |
|
|
819
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
63 |
var params = { |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
64 |
"allowScriptAccess" : "always", |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
65 |
"wmode": "opaque", |
| 842 | 66 |
"flashvars" : IriSP.jQuery.param(_flashVars), |
| 841 | 67 |
"allowfullscreen" : true |
|
819
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
68 |
}; |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
69 |
var atts = { |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
70 |
id : this.container |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
71 |
}; |
| 841 | 72 |
swfobject.embedSWF(options.acPlayerUrl, this.container, options.width, options.height, "10", null, null, params, atts); |
|
819
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
73 |
|
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
74 |
}; |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
75 |
|
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
76 |
IriSP.PopcornReplacement.allocine.prototype = new IriSP.PopcornReplacement.player("", {}); |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
77 |
|
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
78 |
IriSP.PopcornReplacement.allocine.prototype.ready = function() { |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
79 |
this.player = document.getElementById(this.container); |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
80 |
this.player.addEventListener("onStateChange", "onAllocineStateChange"); |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
81 |
this.player.cueVideoByUrl(this._options.video); |
| 919 | 82 |
this.trigger("loadedmetadata"); |
|
819
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
83 |
}; |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
84 |
|
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
85 |
IriSP.PopcornReplacement.allocine.prototype.progressHandler = function(progressInfo) { |
| 919 | 86 |
this.trigger("timeupdate"); |
|
819
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
87 |
} |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
88 |
|
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
89 |
|
| 841 | 90 |
IriSP.PopcornReplacement.allocine.prototype.apiCall = function(_method, _arg) { |
91 |
if (this.player) { |
|
92 |
try { |
|
93 |
if (typeof _arg == "undefined") { |
|
94 |
return this.player.sendToActionScript(_method); |
|
95 |
} else { |
|
96 |
return this.player.sendToActionScript(_method, _arg); |
|
97 |
} |
|
98 |
} catch(e) { |
|
99 |
console.error('Exception while requesting AcPlayer for "' + _method + (typeof _arg == "undefined" ? '' : '" with argument "' + _arg ) + '"\n', e); |
|
100 |
return false; |
|
101 |
} |
|
102 |
} else { |
|
103 |
return false; |
|
104 |
} |
|
105 |
} |
|
106 |
||
|
819
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
107 |
IriSP.PopcornReplacement.allocine.prototype.stateHandler = function(state) { |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
108 |
switch(state) { |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
109 |
case 1: |
| 919 | 110 |
this.trigger("play"); |
|
819
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
111 |
break; |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
112 |
|
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
113 |
case 2: |
| 919 | 114 |
this.trigger("pause"); |
|
819
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
115 |
break; |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
116 |
|
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
117 |
case 3: |
| 919 | 118 |
this.trigger("seeked"); |
|
819
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
119 |
break; |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
120 |
} |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
121 |
|
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
122 |
}; |