JScript1.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. U.PL.vi = (function () {
  2. var _UME, _ = function (UDE, UDPD, UCE) {
  3. if ($$("video").canPlayType) { return new _UME.init(UDE, UDPD, UCE); }
  4. else { return false; }
  5. }
  6. _UME = _.prototype = {
  7. type: { "ogg": 'video/ogg; codecs="theora, vorbis"', "mp4": 'video/mp4; codecs="avc1.42E01E, mp4a.40.2"', "webm": 'audio/webm; codecs="vorbis"' },
  8. 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属性
  9. config: function (UDE) { //配置文件
  10. _$((this.cf = this.cf || {})).Add(UDE); _$(this.cf).Add({ l: this.cf.l || 0, urls: this.cf.urls || [] }); //配置视频
  11. },
  12. init: function (UDE, UDPD, UCE) { //初始化视屏播放器
  13. _$(this).Add({ obj: UDE || {}, pa: UDPD, vi: null }); this.config(UCE); return this;
  14. },
  15. create: function (URL, UDPD) { //src poster preload autoplay loop controls width height viode属性
  16. var _UCE = this.cf, _UVE = _UCE.html || { "style": { "cssText": "margin:auto;display:block;height:100%;width:auto;" }, "autoplay": "autoplay", "controls": "controls", "accesskey": true, "poster": "" };
  17. if ((URL = ((this.cf.urls.push(URL), URL) || this.cf.urls[this.l]))) {
  18. 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])) { };
  19. }
  20. else { U.Alert("链接无效"); }
  21. return this;
  22. },
  23. load: function (URL) { //重新加载
  24. URL = URL || this.cf.urls[this.cf.l]; if (this.vi) { this.vi.url = URL; } else { this.create(); }
  25. },
  26. event: function () { //事件监听
  27. var i, _UDOD = this.vi; //监听所有的事件
  28. 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]])]])); } }
  29. },
  30. cb: function (UTP) { //所有事件监听回调
  31. (this.cf[UTP]) && (this.cf[UTP])(); //回调函数
  32. return true;
  33. },
  34. getType: function (UTF) { //获取属性
  35. return this.vi[this.attr[UTF] || UTF];
  36. },
  37. set: function (UTP, UV) { //设置值
  38. var i, _UAE = this.attr, _USE = UTP; (U.M.isString(UTP)) && (_USE = {}, _USE[UTP] = UV);
  39. for (i in _USE) { this.vi[(_UAE[i] || i)] = _USE[i]; }
  40. },
  41. exec: function (UTF) { //执行获取
  42. return this[UTF] ? this[UTF]() : this.vi[UTF];
  43. },
  44. next: function () { //上一片
  45. 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); }
  46. },
  47. lower: function () { //下一篇片
  48. 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); }
  49. },
  50. isPaly: function (UTF, UDOD) { //判断是否允许播放该格式
  51. return (UDOD || this.vi).canPlayType(this.type[UTF.toLowerCase()]);
  52. },
  53. play: function (UTF) { //播放和暂停
  54. this.vi[UTF ? "play" : "pause"]();
  55. },
  56. backRate: function (UVE) { //播放速度
  57. this.vi.playbackRate = UVE;
  58. },
  59. error: function (UE) { //发生错误
  60. var _UDE = ["", "网络异常", "解码失败", "URL无效"];
  61. (!UE.code) && (U.Alert(_UDE[UE.code]));
  62. },
  63. full: function () {//全屏
  64. (this.vi) && (U.M.fullScreen(this.vi));
  65. }
  66. }
  67. _UME.init.prototype = _UME; return _;
  68. })()