PageSourceSearch

https://statics.haiwainet.cn/tpl2020/2020-05-14/videojs/script/videojs/HwwVideo.js

js haiwainet.cn collected 2026-09-24 19:38:07 UTC 12,012 bytes, 302 lines download raw bytes

1var videoPlug_s = {�
2    main: false,�
3    flash: false�
4};�
5�
6(function (videoPlug_s) {�
7    _watch(videoPlug_s, "main");�
8    _watch(videoPlug_s, "flash");�
9    var urlProtocol=document.location.protocol�
10    if (typeof Promise == 'undefined') {�
11        var scriptObj = document.createElement('script');�
12        scriptObj.type = "text/javascript";�
13        scriptObj.src = "https://cdn.bootcdn.net/ajax/libs/es6-promise/4.1.1/es6-promise.auto.min.js";�
14        var headObj = document.getElementsByTagName('head')[0];�
15        headObj.appendChild(scriptObj);�
16        scriptObj.onload = function () {�
17            hwwVideoPlugin();�
18        }�
19    } else {�
20        hwwVideoPlugin();�
21    }�
22    function hwwVideoPlugin() {�
23        _include_css(urlProtocol+'//statics.haiwainet.cn/tpl2020/2020-05-14/videojs/css/video-js.min.css');�
24        _include_js(urlProtocol+'//statics.haiwainet.cn/tpl2020/2020-05-14/videojs/script/videojs/video.min.js').then(function (response) {�
25        _include_js(urlProtocol+'//statics.haiwainet.cn/tpl2020/2020-05-14/videojs/script/videojs/videojs-ie8.min.js').then(function (response) {�
26            });�
27        // handle success �
28        videoPlug_s.setAttr("main", true);�
29        _include_js(urlProtocol+'//statics.haiwainet.cn/tpl2020/2020-05-14/videojs/script/videojs/videojs-flash.js').then(function (response) {�
30                videoPlug_s.setAttr("flash", true);�
31            });�
32            console.log("插件引入成功");�
33        }).catch(function (error) {�
34                // handle error�
35                console.log("videojs引入失败:", error);�
36            })�
37        // .finally(function () {�
38�
39        //     console.log("插件引入完毕");�
40�
41        // });�
42    }�
43    function _include_js(path) {�
44        return new Promise(function (resolve, reject) {�
45            var sobj = document.createElement('script');�
46            sobj.type = "text/javascript";�
47            sobj.src = path;�
48            var headobj = document.getElementsByTagName('head')[0];�
49            headobj.appendChild(sobj);�
50            sobj.onload = function () {�
51                resolve();�
52            }�
53        })�
54    }�
55�
56    function _include_css(path) {�
57        return new Promise(function (resolve, reject) {�
58            var fileref = document.createElement("link")�
59            fileref.rel = "stylesheet";�
60            fileref.type = "text/css";�
61            fileref.href = path;�
62            var headobj = document.getElementsByTagName('head')[0];�
63            headobj.appendChild(fileref);�
64        });�
65    }�
66})(videoPlug_s);�
67�
68//正式�
69function createVideo(videos) {�
70    this.videosOptions = videos;�
71    var urlProtocol=document.location.protocol;�
72    //吝劍�
73    if (!videoPlug_s.main) {�
74�
75        _watch(videoPlug_s, "main", function (obj) {�
76            if (obj.main == true) {�
77                init(videos);�
78            }�
79        });�
80    } else {�
81        init();�
82    }�
83    //启动函数�
84    function init() {�
85        var _self = this;�
86        for (var i = 0; i < this.videosOptions.length; i++) {�
87            var videoUrl=_self.videosOptions[i].videoSrc.split("//");�
88            if(videoUrl[0]!=urlProtocol){�
89                 _self.videosOptions[i].videoSrc=urlProtocol+"//"+videoUrl[1];�
90                �
91            }�
92            switch (true) {�
93                //vms下获取mp4资源�
94                case _self.videosOptions[i].type == "vms" && _self.videosOptions[i].sourceType == "video/mp4":�
95                    vmsGetMP4(_self.videosOptions[i].videoSrc, i);�
96                    _watch(_self.videosOptions[i], "videoSrc", mp4VMS);�
97                    break;�
98                case _self.videosOptions[i].type == "rtmp" && videoPlug_s.flash == false:�
99                    var t = i;�
100                    _watch(videoPlug_s, "flash", function () { _self.videosOptions[t].videoPlayer = creatDom(_self.videosOptions[t]) });�
101                    break;�
102                default: this.videosOptions[i].videoPlayer = creatDom(_self.videosOptions[i]);�
103            }�
104        }�
105    }�
106    //vms mp4 获取后📛地址后处理�
107    function mp4VMS(obj) {�
108        switch (true) {�
109            case obj.videoSrc.indexOf(".mp4") != -1: obj.videoPlayer = creatDom(obj);�
110                break;�
111            case obj.videoSrc.indexOf(".mov") != -1: obj.sourceType = "video/flv"; obj.videoPlayer = creatDom(obj);�
112                break;�
113        }�
114        // if (obj.videoSrc.indexOf(".mp4") != -1) {�
115        //     obj.videoPlayer = creatDom(obj);�
116        // } else {�
117        //     //获取资源错误处理�
118        // }�
119    }�
120    //检测浏览器属性�
121    function evCheck() {�
122        var ev = {};�
123        var browser = {�
124            versions: function () {�
125                var u = navigator.userAgent, app = navigator.appVersion;�
126                return {//移动终端浏览器版本信息�
127                    trident: u.indexOf('Trident') > -1, //IE内核�
128                    presto: u.indexOf('Presto') > -1, //opera内核�
129                    webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核�
130                    gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, //火狐内核�
131                    mobile: !!u.match(/AppleWebKit.*Mobile.*/) || !!u.match(/AppleWebKit/), //是否为移动终端�
132                    ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端�
133                    android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android终端或者uc浏览器�
134                    iPhone: u.indexOf('iPhone') > -1, //是否为iPhone或者QQHD浏览器�
135                    iPad: u.indexOf('iPad') > -1, //是否iPad�
136                    webApp: u.indexOf('Safari') == -1 //是否web应该程序,没有头部与底部�
137                };�
138            }(),�
139            language: (navigator.browserLanguage || navigator.language).toLowerCase()�
140        }�
141        if (browser.versions.iPhone || browser.versions.iPad || browser.versions.android) {�
142            ev.terminal = "wap";�
143        } else {�
144            ev.terminal = "PC"�
145        }�
146        browser.versions.iPhone ? ev.iPhone = true : ev.iPhone = false;�
147        return ev;�
148    }�
149    //从vms系统获取mp4�
150    function vmsGetMP4(id, i) {�
151        _jsonp(urlProtocol+"//tvplayer.people.com.cn/getXMLForHW.php?path=" + id)�
152            .then(function (response) {�
153                // handle success�
154                this.videosOptions[i].setAttr("videoSrc", response);�
155            })�
156            .catch(function (error) {�
157                // handle error�
158                console.log("vms资源出错,请核实📛是否生成。", error);�
159            })�
160        // .finally(function () {�
161        //     console.log("vms 还活着!");�
162        // });�
163    }�
164�
165    //creat video Dom�
166    function creatDom(opt) {�
167        var ev = evCheck();�
168        var video = document.createElement("VIDEO");�
169        var videoBox = document.getElementById(opt.el);�
170        // var size =�
171        //   "width:" +�
172        //   videoBox.clientWidth +�
173        //   "px; height : " +�
174        //   videoBox.clientHeight +�
175        //   "px ;";�
176        var size = "width:100%; height : 100%;";�
177        var flash=false;�
178        video.className = "hwwvideo video-js vjs-big-play-centered";�
179        if (document.getElementById(opt.el + "_video")) {�
180            return;�
181        } else {�
182            videoBox.appendChild(video);�
183        }�
184�
185�
186        // 各种属性的一批 �
187        video.setAttribute("id", opt.el + "_video");�
188        video.setAttribute("style", size);�
189        if (ev.iPhone) {�
190            video.setAttribute("webkit-playsinline", true);�
191            video.setAttribute("playsinline", true);�
192        }�
193        if (opt.type == "rtmp" || opt.videoSrc.indexOf(".mov") != -1){�
194            flash=true;�
195        }�
196        var finalOption = {�
197            techOrder: flash? ["flash","html5"] : ["html5"],�
198            autoplay: opt.type == "hls"? true:false,�
199            controls: true,�
200            language: 'zh-CN',�
201            poster: opt.poster,�
202            muted: (ev.terminal == "wap") ? true : false,�
203            sources: [ // 视频源�
204                {�
205                    src: opt.videoSrc,�
206                    type: opt.sourceType,�
207                    // poster: opt.poster�
208                }�
209            ],�
210            controlBar: { // 设置控制条组件�
211                /* 设置控制条里面组件的相关属性及显示与否*/�
212                'currentTimeDisplay': true,�
213                'timeDivider': true,�
214                'durationDisplay': true,�
215                'remainingTimeDisplay': false,�
216                volumePanel: {�
217                    inline: false,�
218                    CurrentTimeDisplay: true�
219                },�
220                /* 使用children的形式可以控制每一个控件的位置,以及显示与否 */�
221                // children: [�
222                //   {name: 'progressControl'}, // 播放进度条�
223                //   {name: 'playToggle'}, // 播放按钮�
224                //   {name: 'currentTimeDisplay'}, // 当前已播放时间�
225                //   {name:'timeDivider'},�
226                //   {name: 'durationDisplay'}, // 总时间�
227                //   {�
228                //     name: 'volumePanel', // 音量控制�
229                //     inline: false, // 不使用水平方式�
230                //   },�
231                //   {name: 'FullscreenToggle'} // 全屏�
232                // ]�
233            },�
234        };�
235        var videoObj = videojs(opt.el + "_video", finalOption, function () {�
236            var _self = this;�
237            console.log(this);�
238            this.on('error', function () {�
239                _self.errorDisplay.close();   //将错误信息不显示�
240                console.log(_self.error);�
241            });�
242            this.on('canplaythrough', function () {�
243                _self.muted(false);�
244            })�
245            this.on('touchstart', function (e) {�
246                console.log("点我了",e);�
247                _self.paused() ? _self.play() : _self.pause();�
248            })�
249            this.on('click', function () {�
250                console.log("鼠我了");�
251            })�
252        });�
253        return videoObj�
254    }�
255    //get jsonp 方法�
256    function _jsonp(url) {�
257        if (!url) {�
258            console.error("Axios.JSONP 至少需要一个url参数!");�
259            return;�
260        }�
261        return new Promise(function (resolve, reject) {�
262            var str =�
263                "haiwai_jsonp_" +�
264                Math.floor(Math.random() * 100) +�
265                new Date().getTime();�
266�
267            window[str] = function (result) {�
268                resolve(result);�
269            };�
270            var JSONP = document.createElement("script");�
271            JSONP.type = "text/javascript";�
272            JSONP.src = url + "&callback=" + str;�
273            document.getElementsByTagName("head")[0].appendChild(JSONP);�
274        });�
275    }�
276�
277�
278}�
279//监听属性变化�
280function _watch(obj, attr, callback) {�
281    if (typeof obj.defaultValues == "undefined") {�
282        obj.defaultValues = {};�
283        for (var p in obj) {�
284            if (typeof obj[p] !== "object") obj.defaultValues[p] = obj[p];�
285        }�
286    }�
287    if (typeof obj.setAttr != "undefined") {�
288        delete obj.setAttr�
289    }�
290    obj.setAttr = function (attr, value) {�
291        if (this[attr] != value) {�
292            this.defaultValues[attr] = this[attr];�
293            this[attr] = value;�
294            if (typeof callback === "function") {�
295                return callback(this);�
296            }�
297        }�
298        return this;�
299    };�
300}�
301�
302�

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.