| author | veltr |
| Fri, 20 Jul 2012 17:15:53 +0200 | |
| branch | new-model |
| changeset 928 | 5aadbc9f27cd |
| parent 919 | 972099304059 |
| child 957 | 4da0a5740b6c |
| 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 |
|
| 884 | 35 |
window.onReady = function() { |
36 |
_this.ready(); |
|
37 |
}; |
|
38 |
window.onAllocineStateChange = function(_state) { |
|
39 |
_this.stateHandler(_state) |
|
40 |
} |
|
41 |
window.onTime = function(_progress) { |
|
42 |
_this.progressHandler(_progress) |
|
43 |
}; |
|
|
819
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
44 |
|
| 842 | 45 |
var _flashVars = { |
46 |
"streamFMS" : true, |
|
47 |
"adVast" : false, |
|
48 |
"lg" : "fr_cinecast", |
|
49 |
"autoPlay" : options.autoPlay, |
|
50 |
"directVideoTitle" : "", |
|
51 |
"urlAcData" : options.urlAcData, |
|
| 866 | 52 |
"directVideoPath" : options.video, |
| 842 | 53 |
"host" : "http://allocine.fr" |
54 |
} |
|
| 822 | 55 |
|
| 842 | 56 |
if (typeof IriSP.__jsonMetadata["medias"][0].meta == "object" && typeof IriSP.__jsonMetadata["medias"][0].meta.subtitles == "string") { |
57 |
_flashVars.subTitlePath = IriSP.__jsonMetadata["medias"][0].meta.subtitles; |
|
58 |
} |
|
|
819
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
59 |
|
| 842 | 60 |
|
|
819
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
61 |
var params = { |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
62 |
"allowScriptAccess" : "always", |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
63 |
"wmode": "opaque", |
| 842 | 64 |
"flashvars" : IriSP.jQuery.param(_flashVars), |
| 841 | 65 |
"allowfullscreen" : true |
|
819
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
66 |
}; |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
67 |
var atts = { |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
68 |
id : this.container |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
69 |
}; |
| 841 | 70 |
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
|
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 |
|
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
74 |
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
|
75 |
|
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
76 |
IriSP.PopcornReplacement.allocine.prototype.ready = function() { |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
77 |
this.player = document.getElementById(this.container); |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
78 |
this.player.addEventListener("onStateChange", "onAllocineStateChange"); |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
79 |
this.player.cueVideoByUrl(this._options.video); |
| 919 | 80 |
this.trigger("loadedmetadata"); |
|
819
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 |
|
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
83 |
IriSP.PopcornReplacement.allocine.prototype.progressHandler = function(progressInfo) { |
| 919 | 84 |
this.trigger("timeupdate"); |
|
819
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 |
|
| 841 | 88 |
IriSP.PopcornReplacement.allocine.prototype.apiCall = function(_method, _arg) { |
89 |
if (this.player) { |
|
90 |
try { |
|
91 |
if (typeof _arg == "undefined") { |
|
92 |
return this.player.sendToActionScript(_method); |
|
93 |
} else { |
|
94 |
return this.player.sendToActionScript(_method, _arg); |
|
95 |
} |
|
96 |
} catch(e) { |
|
97 |
console.error('Exception while requesting AcPlayer for "' + _method + (typeof _arg == "undefined" ? '' : '" with argument "' + _arg ) + '"\n', e); |
|
98 |
return false; |
|
99 |
} |
|
100 |
} else { |
|
101 |
return false; |
|
102 |
} |
|
103 |
} |
|
104 |
||
|
819
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
105 |
IriSP.PopcornReplacement.allocine.prototype.stateHandler = function(state) { |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
106 |
switch(state) { |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
107 |
case 1: |
| 919 | 108 |
this.trigger("play"); |
|
819
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 |
case 2: |
| 919 | 112 |
this.trigger("pause"); |
|
819
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
113 |
break; |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
114 |
|
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
115 |
case 3: |
| 919 | 116 |
this.trigger("seeked"); |
|
819
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
117 |
break; |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
118 |
} |
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
119 |
|
|
9b8e68803f6f
add allocine player, and add an full test with this allocine player.
cavaliet
parents:
diff
changeset
|
120 |
}; |