filesbox/web/dist/design/designstatic/chatroom/video/videojs-flash.min.js
2024-07-26 14:10:54 +08:00

7 lines
7.8 KiB
JavaScript

/**
* videojs-flash
* @version 2.1.1
* @copyright 2018 Brightcove, Inc.
* @license Apache-2.0
*/(function(a,u){typeof exports=="object"&&typeof module!="undefined"?module.exports=u(require("video.js")):typeof define=="function"&&define.amd?define(["video.js"],u):a.videojsFlash=u(a.videojs)})(this,function(a){"use strict";function u(r){var t=r.charAt(0).toUpperCase()+r.slice(1);T["set"+t]=function(e){return this.el_.vjs_setProperty(r,e)}}function w(r){T[r]=function(){return this.el_.vjs_getProperty(r)}}a=a&&a.hasOwnProperty("default")?a.default:a;for(var b=typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},s=typeof window!="undefined"?window:b!==void 0?b:typeof self!="undefined"?self:{},P=function(r,t){if(!(r instanceof t))throw new TypeError("Cannot call a class as a function")},F=function(r,t){if(!r)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||typeof t!="object"&&typeof t!="function"?r:t},v=a.getComponent("Tech"),p=a.dom,_=a.url,f=a.createTimeRange,l=a.mergeOptions,m=s&&s.navigator||{},o=function(r){function t(e,n){P(this,t);var i=F(this,r.call(this,e,n));return e.source&&i.ready(function(){this.setSource(e.source)},!0),e.startTime&&i.ready(function(){this.load(),this.play(),this.currentTime(e.startTime)},!0),s.videojs=s.videojs||{},s.videojs.Flash=s.videojs.Flash||{},s.videojs.Flash.onReady=t.onReady,s.videojs.Flash.onEvent=t.onEvent,s.videojs.Flash.onError=t.onError,i.on("seeked",function(){this.lastSeekTarget_=void 0}),i}return function(e,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof n);e.prototype=Object.create(n&&n.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),n&&(Object.setPrototypeOf?Object.setPrototypeOf(e,n):e.__proto__=n)}(t,r),t.prototype.createEl=function(){var e=this.options_;e.swf||(e.swf="https://vjs.zencdn.net/swf/5.4.1/video-js.swf");var n=e.techId,i=l({readyFunction:"videojs.Flash.onReady",eventProxyFunction:"videojs.Flash.onEvent",errorEventProxyFunction:"videojs.Flash.onError",autoplay:e.autoplay,preload:e.preload,loop:e.loop,muted:e.muted},e.flashVars),h=l({wmode:"opaque",bgcolor:"#000000"},e.params),y=l({id:n,name:n,class:"vjs-tech"},e.attributes);return this.el_=t.embed(e.swf,i,h,y),this.el_.tech=this,this.el_},t.prototype.play=function(){this.ended()&&this.setCurrentTime(0),this.el_.vjs_play()},t.prototype.pause=function(){this.el_.vjs_pause()},t.prototype.src=function(e){return e===void 0?this.currentSrc():this.setSrc(e)},t.prototype.setSrc=function(e){var n=this;e=_.getAbsoluteURL(e),this.el_.vjs_src(e),this.autoplay()&&this.setTimeout(function(){return n.play()},0)},t.prototype.seeking=function(){return this.lastSeekTarget_!==void 0},t.prototype.setCurrentTime=function(e){var n=this.seekable();n.length&&(e=(e=e>n.start(0)?e:n.start(0))<n.end(n.length-1)?e:n.end(n.length-1),this.lastSeekTarget_=e,this.trigger("seeking"),this.el_.vjs_setProperty("currentTime",e),r.prototype.setCurrentTime.call(this))},t.prototype.currentTime=function(){return this.seeking()?this.lastSeekTarget_||0:this.el_.vjs_getProperty("currentTime")},t.prototype.currentSrc=function(){return this.currentSource_?this.currentSource_.src:this.el_.vjs_getProperty("currentSrc")},t.prototype.duration=function(){if(this.readyState()===0)return NaN;var e=this.el_.vjs_getProperty("duration");return e>=0?e:Infinity},t.prototype.load=function(){this.el_.vjs_load()},t.prototype.poster=function(){this.el_.vjs_getProperty("poster")},t.prototype.setPoster=function(){},t.prototype.seekable=function(){var e=this.duration();return e===0?f():f(0,e)},t.prototype.buffered=function(){var e=this.el_.vjs_getProperty("buffered");return e.length===0?f():f(e[0][0],e[0][1])},t.prototype.supportsFullScreen=function(){return!1},t.prototype.enterFullScreen=function(){return!1},t.prototype.getVideoPlaybackQuality=function(){var e=this.el_.vjs_getProperty("getVideoPlaybackQuality");return s.performance&&typeof s.performance.now=="function"?e.creationTime=s.performance.now():s.performance&&s.performance.timing&&typeof s.performance.timing.navigationStart=="number"&&(e.creationTime=s.Date.now()-s.performance.timing.navigationStart),e},t}(v),g=["rtmpConnection","rtmpStream","preload","defaultPlaybackRate","playbackRate","autoplay","loop","controls","volume","muted","defaultMuted"],j=["networkState","readyState","initialTime","startOffsetTime","paused","ended","videoWidth","videoHeight"],T=o.prototype,d=0;d<g.length;d++)w(g[d]),u(g[d]);for(var S=0;S<j.length;S++)w(j[S]);return o.isSupported=function(){return!!(a.browser.IS_CHROME&&!a.browser.IS_ANDROID||a.browser.IS_SAFARI&&!a.browser.IS_IOS)||o.version()[0]>=10},v.withSourceHandlers(o),o.nativeSourceHandler={},o.nativeSourceHandler.canPlayType=function(r){return r in o.formats?"maybe":""},o.nativeSourceHandler.canHandleSource=function(r,t){var e=void 0;return e=r.type?r.type.replace(/;.*/,"").toLowerCase():function(n){var i=_.getFileExtension(n);return i?"video/"+i:""}(r.src),o.nativeSourceHandler.canPlayType(e)},o.nativeSourceHandler.handleSource=function(r,t,e){t.setSrc(r.src)},o.nativeSourceHandler.dispose=function(){},o.registerSourceHandler(o.nativeSourceHandler),o.formats={"video/flv":"FLV","video/x-flv":"FLV","video/mp4":"MP4","video/m4v":"MP4"},o.onReady=function(r){var t=p.$("#"+r),e=t&&t.tech;e&&e.el()&&o.checkReady(e)},o.checkReady=function(r){r.el()&&(r.el().vjs_getProperty?r.triggerReady():this.setTimeout(function(){o.checkReady(r)},50))},o.onEvent=function(r,t){var e=p.$("#"+r).tech,n=Array.prototype.slice.call(arguments,2);e.setTimeout(function(){e.trigger(t,n)},1)},o.onError=function(r,t){var e=p.$("#"+r).tech;if(t==="srcnotfound")return e.error(4);typeof t=="string"?e.error("FLASH: "+t):(t.origin="flash",e.error(t))},o.version=function(){var r="0,0,0";try{r=new s.ActiveXObject("ShockwaveFlash.ShockwaveFlash").GetVariable("$version").replace(/\D+/g,",").match(/^,?(.+),?$/)[1]}catch(t){try{m.mimeTypes["application/x-shockwave-flash"].enabledPlugin&&(r=(m.plugins["Shockwave Flash 2.0"]||m.plugins["Shockwave Flash"]).description.replace(/\D+/g,",").match(/^,?(.+),?$/)[1])}catch(e){}}return r.split(",")},o.embed=function(r,t,e,n){var i=o.getEmbedCode(r,t,e,n);return p.createEl("div",{innerHTML:i}).childNodes[0]},o.getEmbedCode=function(r,t,e,n){var i="",h="",y="";return t&&Object.getOwnPropertyNames(t).forEach(function(c){i+=c+"="+t[c]+"&amp;"}),e=l({movie:r,flashvars:i,allowScriptAccess:"always",allowNetworking:"all"},e),Object.getOwnPropertyNames(e).forEach(function(c){h+='<param name="'+c+'" value="'+e[c]+'" />'}),n=l({data:r,width:"100%",height:"100%"},n),Object.getOwnPropertyNames(n).forEach(function(c){y+=c+'="'+n[c]+'" '}),'<object type="application/x-shockwave-flash" '+y+">"+h+"</object>"},function(r){r.streamingFormats={"rtmp/mp4":"MP4","rtmp/flv":"FLV"},r.streamFromParts=function(t,e){return t+"&"+e},r.streamToParts=function(t){var e={connection:"",stream:""};if(!t)return e;var n=t.search(/&(?!\w+=)/),i=void 0;return n!==-1?i=n+1:(n=i=t.lastIndexOf("/")+1)===0&&(n=i=t.length),e.connection=t.substring(0,n),e.stream=t.substring(i,t.length),e},r.isStreamingType=function(t){return t in r.streamingFormats},r.RTMP_RE=/^rtmp[set]?:\/\//i,r.isStreamingSrc=function(t){return r.RTMP_RE.test(t)},r.rtmpSourceHandler={},r.rtmpSourceHandler.canPlayType=function(t){return r.isStreamingType(t)?"maybe":""},r.rtmpSourceHandler.canHandleSource=function(t,e){var n=r.rtmpSourceHandler.canPlayType(t.type);return n||(r.isStreamingSrc(t.src)?"maybe":"")},r.rtmpSourceHandler.handleSource=function(t,e,n){var i=r.streamToParts(t.src);e.setRtmpConnection(i.connection),e.setRtmpStream(i.stream)},r.registerSourceHandler(r.rtmpSourceHandler)}(o),v.getTech("Flash")?(a.log.warn("Not using videojs-flash as it appears to already be registered"),a.log.warn("videojs-flash should only be used with video.js@6 and above")):a.registerTech("Flash",o),o.VERSION="2.1.1",o});