| author | veltr |
| Fri, 06 Apr 2012 16:49:32 +0200 | |
| branch | popcorn-port |
| changeset 842 | 4ae2247a59f4 |
| parent 841 | 8da49ff273e0 |
| child 866 | 3bf7aa8216e5 |
| permissions | -rw-r--r-- |
|
819
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
1 |
/* 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
|
2 |
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
|
3 |
|
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
4 |
/** allocine player wrapper */ |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
5 |
IriSP.PopcornReplacement.allocine = function(container, options) { |
| 822 | 6 |
// console.log("Calling allocine player"); |
|
819
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
7 |
/* 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
|
8 |
IriSP.PopcornReplacement.player.call(this, container, options); |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
9 |
|
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
10 |
var _this = this; |
|
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 |
/* Définition des fonctions de l'API - */ |
|
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 |
this.playerFns = { |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
15 |
play : function() { |
| 841 | 16 |
return _this.apiCall("play"); |
|
819
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
17 |
}, |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
18 |
pause : function() { |
| 841 | 19 |
return _this.apiCall("pause"); |
|
819
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
20 |
}, |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
21 |
getPosition : function() { |
| 841 | 22 |
return _this.apiCall("getSeek","return") || 0; |
|
819
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
23 |
}, |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
24 |
seek : function(pos) { |
| 841 | 25 |
return _this.apiCall("seek",pos); |
|
819
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
26 |
}, |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
27 |
getMute : function() { |
| 841 | 28 |
return _this.apiCall("getMute","return"); |
|
819
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
29 |
}, |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
30 |
setMute : function(p) { |
| 841 | 31 |
return _this.apiCall("setMute", p); |
|
819
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
32 |
} |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
33 |
} |
|
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 |
window.onReady = IriSP.wrap(this, this.ready); |
| 839 | 36 |
window.onAllocineStateChange = IriSP.wrap(this, this.stateHandler); |
|
819
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
37 |
window.onTime = IriSP.wrap(this, this.progressHandler); |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
38 |
|
| 822 | 39 |
var _videoUrl = ( |
40 |
typeof options.directVideoPath == "string" |
|
41 |
? options.directVideoPath |
|
42 |
: IriSP.get_aliased(IriSP.__jsonMetadata["medias"][0], ["href","url"]) |
|
43 |
); |
|
| 842 | 44 |
var _flashVars = { |
45 |
"streamFMS" : true, |
|
46 |
"adVast" : false, |
|
47 |
"lg" : "fr_cinecast", |
|
48 |
"autoPlay" : options.autoPlay, |
|
49 |
"directVideoTitle" : "", |
|
50 |
"urlAcData" : options.urlAcData, |
|
51 |
"directVideoPath" : _videoUrl, |
|
52 |
"host" : "http://allocine.fr" |
|
53 |
} |
|
| 822 | 54 |
|
| 842 | 55 |
if (typeof IriSP.__jsonMetadata["medias"][0].meta == "object" && typeof IriSP.__jsonMetadata["medias"][0].meta.subtitles == "string") { |
56 |
_flashVars.subTitlePath = IriSP.__jsonMetadata["medias"][0].meta.subtitles; |
|
57 |
} |
|
|
819
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
58 |
|
| 842 | 59 |
|
|
819
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
60 |
var params = { |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
61 |
"allowScriptAccess" : "always", |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
62 |
"wmode": "opaque", |
| 842 | 63 |
"flashvars" : IriSP.jQuery.param(_flashVars), |
| 841 | 64 |
"allowfullscreen" : true |
|
819
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
65 |
}; |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
66 |
var atts = { |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
67 |
id : this.container |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
68 |
}; |
| 841 | 69 |
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
|
70 |
|
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
71 |
}; |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
72 |
|
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
73 |
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
|
74 |
|
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
75 |
IriSP.PopcornReplacement.allocine.prototype.ready = function() { |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
76 |
this.player = document.getElementById(this.container); |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
77 |
this.player.addEventListener("onStateChange", "onAllocineStateChange"); |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
78 |
this.player.cueVideoByUrl(this._options.video); |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
79 |
this.callbacks.onReady(); |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
80 |
}; |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
81 |
|
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
82 |
IriSP.PopcornReplacement.allocine.prototype.progressHandler = function(progressInfo) { |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
83 |
this.callbacks.onTime({ |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
84 |
position: progressInfo.mediaTime |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
85 |
}); |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
86 |
} |
|
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 |
|
| 841 | 89 |
IriSP.PopcornReplacement.allocine.prototype.apiCall = function(_method, _arg) { |
90 |
if (this.player) { |
|
91 |
try { |
|
92 |
if (typeof _arg == "undefined") { |
|
93 |
return this.player.sendToActionScript(_method); |
|
94 |
} else { |
|
95 |
return this.player.sendToActionScript(_method, _arg); |
|
96 |
} |
|
97 |
} catch(e) { |
|
98 |
console.error('Exception while requesting AcPlayer for "' + _method + (typeof _arg == "undefined" ? '' : '" with argument "' + _arg ) + '"\n', e); |
|
99 |
return false; |
|
100 |
} |
|
101 |
} else { |
|
102 |
return false; |
|
103 |
} |
|
104 |
} |
|
105 |
||
|
819
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
106 |
IriSP.PopcornReplacement.allocine.prototype.stateHandler = function(state) { |
| 839 | 107 |
console.log("stateHandler"); |
|
819
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: |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
110 |
this.callbacks.onPlay(); |
|
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: |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
114 |
this.callbacks.onPause(); |
|
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: |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
118 |
this.callbacks.onSeek({ |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
119 |
position: this.player.getCurrentTime() |
|
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 |
break; |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
122 |
|
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
123 |
/* |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
124 |
case 5: |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
125 |
this.callbacks.onReady(); |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
126 |
break; |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
127 |
*/ |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
128 |
} |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
129 |
|
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
130 |
}; |