| author | ymh <ymh.work@gmail.com> |
| Sun, 12 Nov 2017 22:07:33 +0100 | |
| changeset 1071 | 02c04d2c8fd8 |
| parent 1042 | a128e59ca2b1 |
| child 1072 | ac1eacb3aa33 |
| permissions | -rw-r--r-- |
| 959 | 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" |
|
| 1013 | 9 |
}; |
| 959 | 10 |
|
11 |
IriSP.Widgets.AutoPlayer.prototype.draw = function() { |
|
|
1071
02c04d2c8fd8
Various changes from git version and make autoplayer determine video type on lowercase url
ymh <ymh.work@gmail.com>
parents:
1042
diff
changeset
|
12 |
|
| 959 | 13 |
if (typeof this.video === "undefined") { |
14 |
this.video = this.media.video; |
|
15 |
} |
|
|
1071
02c04d2c8fd8
Various changes from git version and make autoplayer determine video type on lowercase url
ymh <ymh.work@gmail.com>
parents:
1042
diff
changeset
|
16 |
|
| 959 | 17 |
var _props = [ "live", "provider", "autostart", "streamer", "video", "height", "width", "url_transform" ], |
18 |
_opts = {}, |
|
19 |
_types = [ |
|
20 |
{ |
|
| 976 | 21 |
regexp: /^rtmp:\/\//, |
22 |
type: "JwpPlayer" |
|
23 |
}, |
|
24 |
{ |
|
|
1071
02c04d2c8fd8
Various changes from git version and make autoplayer determine video type on lowercase url
ymh <ymh.work@gmail.com>
parents:
1042
diff
changeset
|
25 |
regexp: /\.(mp4|m4v|mp3)$/, |
| 976 | 26 |
type: "AdaptivePlayer" |
27 |
}, |
|
28 |
{ |
|
| 959 | 29 |
regexp: /\.(ogg|ogv|webm)$/, |
| 987 | 30 |
type: "HtmlPlayer" |
| 959 | 31 |
}, |
32 |
{ |
|
33 |
regexp: /^(https?:\/\/)?(www\.)?youtube\.com/, |
|
34 |
type: "PopcornPlayer" |
|
35 |
}, |
|
36 |
{ |
|
37 |
regexp: /^(https?:\/\/)?(www\.)?vimeo\.com/, |
|
38 |
type: "PopcornPlayer" |
|
39 |
}, |
|
40 |
{ |
|
41 |
regexp: /^(https?:\/\/)?(www\.)?dailymotion\.com/, |
|
42 |
type: "DailymotionPlayer" |
|
43 |
} |
|
| 976 | 44 |
], |
45 |
_rtmprgx = /^rtmp:\/\//; |
|
|
1071
02c04d2c8fd8
Various changes from git version and make autoplayer determine video type on lowercase url
ymh <ymh.work@gmail.com>
parents:
1042
diff
changeset
|
46 |
|
| 959 | 47 |
for (var i = 0; i < _types.length; i++) { |
|
1071
02c04d2c8fd8
Various changes from git version and make autoplayer determine video type on lowercase url
ymh <ymh.work@gmail.com>
parents:
1042
diff
changeset
|
48 |
if (this.video && _types[i].regexp.test(this.video.toLowerCase())) { |
| 979 | 49 |
_opts.type = _types[i].type; |
50 |
break; |
|
| 959 | 51 |
} |
52 |
} |
|
|
1071
02c04d2c8fd8
Various changes from git version and make autoplayer determine video type on lowercase url
ymh <ymh.work@gmail.com>
parents:
1042
diff
changeset
|
53 |
|
| 959 | 54 |
if (typeof _opts.type === "undefined") { |
| 1013 | 55 |
_opts.type = this.default_type; |
| 959 | 56 |
} |
|
1071
02c04d2c8fd8
Various changes from git version and make autoplayer determine video type on lowercase url
ymh <ymh.work@gmail.com>
parents:
1042
diff
changeset
|
57 |
|
| 980 | 58 |
if (_opts.type === "AdaptivePlayer") { |
|
1042
a128e59ca2b1
change h264 detection for adaptive player + auto player
ymh <ymh.work@gmail.com>
parents:
1013
diff
changeset
|
59 |
var _canPlayType = document.createElement('video').canPlayType('video/mp4; codecs="avc1.42E01E"'); |
|
a128e59ca2b1
change h264 detection for adaptive player + auto player
ymh <ymh.work@gmail.com>
parents:
1013
diff
changeset
|
60 |
_opts.type = (_canPlayType !== "no") ? "HtmlPlayer" : "JwpPlayer"; |
| 980 | 61 |
} |
|
1071
02c04d2c8fd8
Various changes from git version and make autoplayer determine video type on lowercase url
ymh <ymh.work@gmail.com>
parents:
1042
diff
changeset
|
62 |
|
| 976 | 63 |
if (_rtmprgx.test(this.video)) { |
64 |
_opts.provider = "rtmp"; |
|
65 |
_opts.live = true; |
|
66 |
} |
|
|
1071
02c04d2c8fd8
Various changes from git version and make autoplayer determine video type on lowercase url
ymh <ymh.work@gmail.com>
parents:
1042
diff
changeset
|
67 |
|
| 959 | 68 |
for (var i = 0; i < _props.length; i++) { |
69 |
if (typeof this[_props[i]] !== "undefined") { |
|
70 |
_opts[_props[i]] = this[_props[i]]; |
|
71 |
} |
|
72 |
} |
|
73 |
||
74 |
this.insertSubwidget(this.$, _opts); |
|
|
1071
02c04d2c8fd8
Various changes from git version and make autoplayer determine video type on lowercase url
ymh <ymh.work@gmail.com>
parents:
1042
diff
changeset
|
75 |
|
|
02c04d2c8fd8
Various changes from git version and make autoplayer determine video type on lowercase url
ymh <ymh.work@gmail.com>
parents:
1042
diff
changeset
|
76 |
}; |