| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 | Namespace.register("U.PL");//#region 变量处理U.PL._er = {};U.PL._ev = ["loadstart", "ended", "progress", "suspend", "abort", "error", "stalled", "play", "pause", "loadedmetadata", "loadeddata", "waiting", "playing", "canplay", "readystatechange", "canplaythrough", "seeking", "seeked", "timeupdate", "ended", "ratechange", "durationchange", "volumechange"]; //vedio所有的事件//#endregoin//视频初始化U.PL.vi = function (UDE, UDPD, UCE) {    if ($$("video").canPlayType) {        return new U.PL.vi.init(UDE, UDPD, UCE);    }    else { return false; }}//初始化视屏播放器U.PL.vi.init = function (UDE, UDPD, UCE) {    this.obj = UDE || {}; //    this.pa = UDPD; //    this.vi = null;//    this.config(UCE);    return this;}U.PL.vi.init.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) { //配置文件        U.Ut.AddObj((this.cf = this.cf || {}), UDE); U.Ut.AddObj(this.cf, { l: this.cf.l || 0, urls: this.cf.urls || [] }); //配置视频    },    init: function (UDE, UDPD, UCE) { //初始化视屏播放器        U.Ut.AddObj(this, { 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 || document.body); this.event(); } if (!U.Ut.isString(URL) && this.vi.srcObject) { this.vi.srcObject = URL } else { this.vi.src = U.Ut.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.Ut.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); }    },    isPlay: 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]));    },    fullScreen: function () {//视频全屏        var _funcname = U.M.GetFullSreeenName("requestFullScreen"); //全屏函数名        if (_funcname != null)            this.vi[_funcname](); //执行全屏函数    },    fullScreen: function () {//取消视频全屏        U.M.cancelfullScreen();    }}
 |