You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

7 lines
7.9 KiB

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