123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- U.PL.vi = (function () {
- var _UME, _ = function (UDE, UDPD, UCE) {
- if ($$("video").canPlayType) { return new _UME.init(UDE, UDPD, UCE); }
- else { return false; }
- }
- _UME = _.prototype = {
- type: { "ogg": 'video/ogg; codecs="theora, vorbis"', "mp4": 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"', "webm": 'audio/webm; codecs="vorbis"' },
- attr: { at: "audioTracks", ap: "autoPlay", bf: "buffered", cl: "controller", cr: "controls", co: "crossOrigin", cs: "currentSrc", cTime: "currentTime", dm: "defaultMuted", dp: "defaultPlaybackRate", dt: "duration", ed: "ended", er: "error", lt: "initialTime", lp: "loop", mg: "mediaGroup", mt: "muted", ns: "networkState", pe: "paused", pr: "playbackRate", sTime: "startTime", pr: "playbackRate", py: "played", pl: "preload", rd: "readyState", si: "seeking", sk: "seekable", st: "startOffsetTime", tt: "textTracks", vt: "videoTracks", vl: "volume" }, // video属性
- config: function (UDE) { //配置文件
- _$((this.cf = this.cf || {})).Add(UDE); _$(this.cf).Add({ l: this.cf.l || 0, urls: this.cf.urls || [] }); //配置视频
- },
- init: function (UDE, UDPD, UCE) { //初始化视屏播放器
- _$(this).Add({ obj: UDE || {}, pa: UDPD, vi: null }); this.config(UCE); return this;
- },
- create: function (URL, UDPD) { //src poster preload autoplay loop controls width height viode属性
- var _UCE = this.cf, _UVE = _UCE.html || { "style": { "cssText": "margin:auto;display:block;height:100%;width:auto;" }, "autoplay": "autoplay", "controls": "controls", "accesskey": true, "poster": "" };
- if ((URL = ((this.cf.urls.push(URL), URL) || this.cf.urls[this.l]))) {
- if (!this.vi) { this.vi = $$("video", _UVE, UDPD || this.pa || doc.body); this.event(); } if (!U.M.isString(URL) && this.vi.srcObject) { this.vi.srcObject = URL } else { this.vi.src = U.M.isString(URL) ? URL : (window.URL || window.webkitURL).createObjectURL(URL); } this.set(this.obj); //if (this.isPaly(U.UP.GetUpName(URL)[1])) { };
- }
- else { U.Alert("链接无效"); }
- return this;
- },
- load: function (URL) { //重新加载
- URL = URL || this.cf.urls[this.cf.l]; if (this.vi) { this.vi.url = URL; } else { this.create(); }
- },
- event: function () { //事件监听
- var i, _UDOD = this.vi; //监听所有的事件
- if (U.PL._ev) { for (i = 0; i < U.PL._ev.length; i++) { U.M.AddEvent(U.PL._ev[i], _UDOD, U.M.apply(this, [[this.cb, ([U.PL._ev[i]])]])); } }
- },
- cb: function (UTP) { //所有事件监听回调
- (this.cf[UTP]) && (this.cf[UTP])(); //回调函数
- return true;
- },
- getType: function (UTF) { //获取属性
- return this.vi[this.attr[UTF] || UTF];
- },
- set: function (UTP, UV) { //设置值
- var i, _UAE = this.attr, _USE = UTP; (U.M.isString(UTP)) && (_USE = {}, _USE[UTP] = UV);
- for (i in _USE) { this.vi[(_UAE[i] || i)] = _USE[i]; }
- },
- exec: function (UTF) { //执行获取
- return this[UTF] ? this[UTF]() : this.vi[UTF];
- },
- next: function () { //上一片
- var _URL; this.cf.l = this.cf.l - 1 < 0 ? this.cf.urls.length - 1 : this.cf.l - 1; if ((_URL = this.cf.urls[this.cf.l])) { this.load(_URL); }
- },
- lower: function () { //下一篇片
- var _URL; this.cf.l = this.cf.l + 1 >= this.cf.urls.length ? 0 : this.cf.l - 1; if ((_URL = this.cf.urls[this.cf.l])) { this.load(_URL); }
- },
- isPaly: function (UTF, UDOD) { //判断是否允许播放该格式
- return (UDOD || this.vi).canPlayType(this.type[UTF.toLowerCase()]);
- },
- play: function (UTF) { //播放和暂停
- this.vi[UTF ? "play" : "pause"]();
- },
- backRate: function (UVE) { //播放速度
- this.vi.playbackRate = UVE;
- },
- error: function (UE) { //发生错误
- var _UDE = ["", "网络异常", "解码失败", "URL无效"];
- (!UE.code) && (U.Alert(_UDE[UE.code]));
- },
- full: function () {//全屏
- (this.vi) && (U.M.fullScreen(this.vi));
- }
- }
- _UME.init.prototype = _UME; return _;
- })()
|