|
765
|
1 |
IriSP.Widgets.HtmlPlayer = function(player, config) { |
|
|
2 |
IriSP.Widgets.Widget.call(this, player, config); |
|
|
3 |
}; |
|
|
4 |
|
|
|
5 |
IriSP.Widgets.HtmlPlayer.prototype = new IriSP.Widgets.Widget(); |
|
|
6 |
|
|
|
7 |
|
|
|
8 |
IriSP.Widgets.HtmlPlayer.prototype.defaults = { |
|
|
9 |
} |
|
|
10 |
|
|
|
11 |
IriSP.Widgets.HtmlPlayer.prototype.draw = function() { |
|
|
12 |
|
|
|
13 |
|
|
|
14 |
if (typeof this.video === "undefined") { |
|
|
15 |
this.video = this.media.video; |
|
|
16 |
} |
|
|
17 |
|
|
|
18 |
if (this.url_transform) { |
|
|
19 |
this.video = this.url_transform(this.video); |
|
|
20 |
} |
|
|
21 |
|
|
|
22 |
var videoEl = IriSP.jQuery('<video>'); |
|
|
23 |
videoEl.attr({ |
|
|
24 |
width : this.width, |
|
|
25 |
height : this.height || undefined |
|
|
26 |
}); |
|
|
27 |
if(typeof this.video === "string"){ |
|
|
28 |
videoEl.attr("src",this.video); |
|
|
29 |
} else { |
|
|
30 |
for (var i = 0; i < this.video.length; i++) { |
|
|
31 |
var _srcNode = IriSP.jQuery('<source>'); |
|
|
32 |
_srcNode.attr({ |
|
|
33 |
src: this.video[i].src, |
|
|
34 |
type: this.video[i].type |
|
|
35 |
}); |
|
|
36 |
videoEl.append(_srcNode); |
|
|
37 |
} |
|
|
38 |
} |
|
|
39 |
this.$.html(videoEl); |
|
|
40 |
if (this.autostart || this.autoplay) { |
|
|
41 |
videoEl.attr("autoplay", true); |
|
|
42 |
} |
|
|
43 |
|
|
|
44 |
var mediaEl = videoEl[0], |
|
|
45 |
media = this.media; |
|
|
46 |
|
|
|
47 |
// Binding functions to Popcorn |
|
|
48 |
media.on("setcurrenttime", function(_milliseconds) { |
|
|
49 |
try { |
|
|
50 |
mediaEl.currentTime = (_milliseconds / 1000); |
|
|
51 |
} catch (err) { |
|
|
52 |
|
|
|
53 |
} |
|
|
54 |
}); |
|
|
55 |
|
|
|
56 |
media.on("setvolume", function(_vol) { |
|
|
57 |
media.volume = _vol; |
|
|
58 |
try { |
|
|
59 |
mediaEl.volume = _vol; |
|
|
60 |
} catch (err) { |
|
|
61 |
|
|
|
62 |
} |
|
|
63 |
}); |
|
|
64 |
|
|
|
65 |
media.on("setmuted", function(_muted) { |
|
|
66 |
media.muted = _muted; |
|
|
67 |
try { |
|
|
68 |
mediaEl.muted = _muted; |
|
|
69 |
} catch (err) { |
|
|
70 |
|
|
|
71 |
} |
|
|
72 |
}); |
|
|
73 |
|
|
|
74 |
media.on("setplay", function() { |
|
|
75 |
try { |
|
|
76 |
mediaEl.play(); |
|
|
77 |
} catch (err) { |
|
|
78 |
|
|
|
79 |
} |
|
|
80 |
}); |
|
|
81 |
|
|
|
82 |
media.on("setpause", function() { |
|
|
83 |
try { |
|
|
84 |
mediaEl.pause(); |
|
|
85 |
} catch (err) { |
|
|
86 |
|
|
|
87 |
} |
|
|
88 |
}); |
|
|
89 |
|
|
|
90 |
// Binding Popcorn events to media |
|
|
91 |
function getVolume() { |
|
|
92 |
media.muted = mediaEl.muted; |
|
|
93 |
media.volume = mediaEl.volume; |
|
|
94 |
} |
|
|
95 |
|
|
|
96 |
videoEl.on("loadedmetadata", function() { |
|
|
97 |
getVolume(); |
|
|
98 |
media.trigger("loadedmetadata"); |
|
|
99 |
media.trigger("volumechange"); |
|
|
100 |
}) |
|
|
101 |
|
|
|
102 |
videoEl.on("timeupdate", function() { |
|
|
103 |
media.trigger("timeupdate", new IriSP.Model.Time(1000*mediaEl.currentTime)); |
|
|
104 |
}); |
|
|
105 |
|
|
|
106 |
videoEl.on("volumechange", function() { |
|
|
107 |
getVolume(); |
|
|
108 |
media.trigger("volumechange"); |
|
|
109 |
}) |
|
|
110 |
|
|
|
111 |
videoEl.on("play", function() { |
|
|
112 |
media.trigger("play"); |
|
|
113 |
}); |
|
|
114 |
|
|
|
115 |
videoEl.on("pause", function() { |
|
|
116 |
media.trigger("pause"); |
|
|
117 |
}); |
|
|
118 |
|
|
|
119 |
videoEl.on("seeking", function() { |
|
|
120 |
media.trigger("seeking"); |
|
|
121 |
}); |
|
|
122 |
|
|
|
123 |
videoEl.on("seeked", function() { |
|
|
124 |
media.trigger("seeked"); |
|
|
125 |
}); |
|
|
126 |
|
|
|
127 |
} |