| author | veltr |
| Tue, 03 Apr 2012 20:30:12 +0200 | |
| branch | popcorn-port |
| changeset 841 | 8da49ff273e0 |
| parent 839 | 4357aac4eb19 |
| child 842 | 4ae2247a59f4 |
| 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 |
); |
|
44 |
|
|
45 |
var fv = "streamFMS=true&adVast=false&lg=fr_cinecast&autoPlay=" + options.autoPlay + "&directVideoTitle=&urlAcData=" + options.urlAcData + "&directVideoPath=" + _videoUrl + "&host=http://allocine.fr"; |
|
46 |
// console.log("fv = " + fv); |
|
|
819
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
47 |
|
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
48 |
var params = { |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
49 |
"allowScriptAccess" : "always", |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
50 |
"wmode": "opaque", |
| 841 | 51 |
"flashvars" : fv, |
52 |
"allowfullscreen" : true |
|
|
819
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
53 |
}; |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
54 |
var atts = { |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
55 |
id : this.container |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
56 |
}; |
| 841 | 57 |
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
|
58 |
|
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
59 |
}; |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
60 |
|
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
61 |
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
|
62 |
|
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
63 |
IriSP.PopcornReplacement.allocine.prototype.ready = function() { |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
64 |
this.player = document.getElementById(this.container); |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
65 |
this.player.addEventListener("onStateChange", "onAllocineStateChange"); |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
66 |
this.player.cueVideoByUrl(this._options.video); |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
67 |
this.callbacks.onReady(); |
|
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 |
|
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
70 |
IriSP.PopcornReplacement.allocine.prototype.progressHandler = function(progressInfo) { |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
71 |
this.callbacks.onTime({ |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
72 |
position: progressInfo.mediaTime |
|
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 |
|
| 841 | 77 |
IriSP.PopcornReplacement.allocine.prototype.apiCall = function(_method, _arg) { |
78 |
if (this.player) { |
|
79 |
try { |
|
80 |
if (typeof _arg == "undefined") { |
|
81 |
return this.player.sendToActionScript(_method); |
|
82 |
} else { |
|
83 |
return this.player.sendToActionScript(_method, _arg); |
|
84 |
} |
|
85 |
} catch(e) { |
|
86 |
console.error('Exception while requesting AcPlayer for "' + _method + (typeof _arg == "undefined" ? '' : '" with argument "' + _arg ) + '"\n', e); |
|
87 |
return false; |
|
88 |
} |
|
89 |
} else { |
|
90 |
return false; |
|
91 |
} |
|
92 |
} |
|
93 |
||
|
819
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
94 |
IriSP.PopcornReplacement.allocine.prototype.stateHandler = function(state) { |
| 839 | 95 |
console.log("stateHandler"); |
|
819
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
96 |
switch(state) { |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
97 |
case 1: |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
98 |
this.callbacks.onPlay(); |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
99 |
break; |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
100 |
|
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
101 |
case 2: |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
102 |
this.callbacks.onPause(); |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
103 |
break; |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
104 |
|
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
105 |
case 3: |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
106 |
this.callbacks.onSeek({ |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
107 |
position: this.player.getCurrentTime() |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
108 |
}); |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
109 |
break; |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
110 |
|
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
111 |
/* |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
112 |
case 5: |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
113 |
this.callbacks.onReady(); |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
114 |
break; |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
115 |
*/ |
|
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 |
|
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
118 |
}; |