|
1019
|
1 |
IriSP.Widgets.DailymotionPlayer = function(player, config) { |
|
|
2 |
IriSP.Widgets.Widget.call(this, player, config); |
|
|
3 |
}; |
|
|
4 |
|
|
|
5 |
IriSP.Widgets.DailymotionPlayer.prototype = new IriSP.Widgets.Widget(); |
|
|
6 |
|
|
|
7 |
IriSP.Widgets.DailymotionPlayer.prototype.defaults = { |
|
|
8 |
aspect_ratio: 14/9 |
|
|
9 |
}; |
|
|
10 |
|
|
|
11 |
IriSP.Widgets.DailymotionPlayer.prototype.draw = function() { |
|
|
12 |
|
|
|
13 |
if (typeof this.video === "undefined") { |
|
|
14 |
this.video = this.media.video; |
|
|
15 |
} |
|
|
16 |
|
|
|
17 |
this.height = this.height || Math.floor(this.width / this.aspect_ratio); |
|
|
18 |
|
|
|
19 |
var _media = this.media, |
|
|
20 |
_this = this, |
|
|
21 |
_pauseState = true; |
|
|
22 |
|
|
|
23 |
/* Dailymotion utilise un système de fonctions référencées dans |
|
|
24 |
* des variables globales pour la gestion des événements. |
|
|
25 |
*/ |
|
|
26 |
|
|
|
27 |
window.onDailymotionPlayerReady = function() { |
|
|
28 |
|
|
|
29 |
var _player = document.getElementById(_this.container); |
|
|
30 |
|
|
|
31 |
_media.getCurrentTime = function() { |
|
|
32 |
return new IriSP.Model.Time(1000*_player.getCurrentTime()); |
|
|
33 |
}; |
|
|
34 |
_media.getVolume = function() { |
|
|
35 |
return _player.getVolume() / 100; |
|
|
36 |
}; |
|
|
37 |
_media.getPaused = function() { |
|
|
38 |
return _pauseState; |
|
|
39 |
}; |
|
|
40 |
_media.getMuted = function() { |
|
|
41 |
return _player.isMuted(); |
|
|
42 |
}; |
|
|
43 |
_media.setCurrentTime = function(_milliseconds) { |
|
|
44 |
_seekPause = _pauseState; |
|
|
45 |
return _player.seekTo(_milliseconds / 1000); |
|
|
46 |
}; |
|
|
47 |
_media.setVolume = function(_vol) { |
|
|
48 |
return _player.setVolume(Math.floor(_vol*100)); |
|
|
49 |
}; |
|
|
50 |
_media.mute = function() { |
|
|
51 |
return _player.mute(); |
|
|
52 |
}; |
|
|
53 |
_media.unmute = function() { |
|
|
54 |
return _player.unMute(); |
|
|
55 |
}; |
|
|
56 |
_media.play = function() { |
|
|
57 |
return _player.playVideo(); |
|
|
58 |
}; |
|
|
59 |
_media.pause = function() { |
|
|
60 |
return _player.pauseVideo(); |
|
|
61 |
}; |
|
|
62 |
|
|
|
63 |
_player.addEventListener("onStateChange", "onDailymotionStateChange"); |
|
|
64 |
_player.addEventListener("onVideoProgress", "onDailymotionVideoProgress"); |
|
|
65 |
|
|
|
66 |
_player.cueVideoByUrl(_this.video); |
|
|
67 |
|
|
|
68 |
_media.trigger("loadedmetadata"); |
|
|
69 |
}; |
|
|
70 |
|
|
|
71 |
window.onDailymotionStateChange = function(_state) { |
|
|
72 |
switch(_state) { |
|
|
73 |
case 1: |
|
|
74 |
_media.trigger("play"); |
|
|
75 |
_pauseState = false; |
|
|
76 |
break; |
|
|
77 |
|
|
|
78 |
case 2: |
|
|
79 |
_media.trigger("pause"); |
|
|
80 |
_pauseState = true; |
|
|
81 |
break; |
|
|
82 |
|
|
|
83 |
case 3: |
|
|
84 |
_media.trigger("seeked"); |
|
|
85 |
break; |
|
|
86 |
} |
|
|
87 |
}; |
|
|
88 |
|
|
|
89 |
window.onDailymotionVideoProgress = function(_progress) { |
|
|
90 |
_media.trigger("timeupdate", new IriSP.Model.Time(_progress.mediaTime * 1000)); |
|
|
91 |
}; |
|
|
92 |
|
|
|
93 |
var params = { |
|
|
94 |
"allowScriptAccess" : "always", |
|
|
95 |
"wmode": "opaque" |
|
|
96 |
}; |
|
|
97 |
|
|
|
98 |
var atts = { |
|
|
99 |
id : this.container |
|
|
100 |
}; |
|
|
101 |
|
|
|
102 |
swfobject.embedSWF("http://www.dailymotion.com/swf?chromeless=1&enableApi=1", this.container, this.width, this.height, "8", null, null, params, atts); |
|
|
103 |
|
|
|
104 |
}; |