|
1 IriSP.Widgets.AutoPlayer = function(player, config) { |
|
2 IriSP.Widgets.Widget.call(this, player, config); |
|
3 }; |
|
4 |
|
5 IriSP.Widgets.AutoPlayer.prototype = new IriSP.Widgets.Widget(); |
|
6 |
|
7 IriSP.Widgets.AutoPlayer.prototype.defaults = { |
|
8 default_type: "JwpPlayer" |
|
9 } |
|
10 |
|
11 IriSP.Widgets.AutoPlayer.prototype.draw = function() { |
|
12 |
|
13 if (typeof this.video === "undefined") { |
|
14 this.video = this.media.video; |
|
15 } |
|
16 |
|
17 var _props = [ "live", "provider", "autostart", "streamer", "video", "height", "width", "url_transform" ], |
|
18 _opts = {}, |
|
19 _types = [ |
|
20 { |
|
21 regexp: /\.(ogg|ogv|webm)$/, |
|
22 type: "PopcornPlayer" |
|
23 }, |
|
24 { |
|
25 regexp: /^(https?:\/\/)?(www\.)?youtube\.com/, |
|
26 type: "PopcornPlayer" |
|
27 }, |
|
28 { |
|
29 regexp: /^(https?:\/\/)?(www\.)?vimeo\.com/, |
|
30 type: "PopcornPlayer" |
|
31 }, |
|
32 { |
|
33 regexp: /^(https?:\/\/)?(www\.)?dailymotion\.com/, |
|
34 type: "DailymotionPlayer" |
|
35 } |
|
36 ]; |
|
37 |
|
38 for (var i = 0; i < _types.length; i++) { |
|
39 if (_types[i].regexp.test(this.video)) { |
|
40 _opts.type = _types[i].type |
|
41 } |
|
42 } |
|
43 |
|
44 if (typeof _opts.type === "undefined") { |
|
45 _opts.type = this.default_type |
|
46 } |
|
47 |
|
48 for (var i = 0; i < _props.length; i++) { |
|
49 if (typeof this[_props[i]] !== "undefined") { |
|
50 _opts[_props[i]] = this[_props[i]]; |
|
51 } |
|
52 } |
|
53 |
|
54 |
|
55 this.insertSubwidget(this.$, _opts); |
|
56 |
|
57 } |