@galacean/effects-plugin-multimedia 2.1.3 → 2.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2 -2
- package/dist/index.min.js +2 -2
- package/dist/index.mjs +2 -2
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Description: Galacean Effects player multimedia plugin
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 云垣
|
|
6
|
-
* Version: v2.1.
|
|
6
|
+
* Version: v2.1.4
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
'use strict';
|
|
@@ -974,7 +974,7 @@ exports.AudioComponent = __decorate([
|
|
|
974
974
|
|
|
975
975
|
/**
|
|
976
976
|
* 插件版本号
|
|
977
|
-
*/ var version = "2.1.
|
|
977
|
+
*/ var version = "2.1.4";
|
|
978
978
|
EFFECTS.registerPlugin("video", VideoLoader, EFFECTS.VFXItem, true);
|
|
979
979
|
EFFECTS.registerPlugin("audio", AudioLoader, EFFECTS.VFXItem, true);
|
|
980
980
|
EFFECTS.logger.info("Plugin multimedia version: " + version + ".");
|
package/dist/index.min.js
CHANGED
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
* Description: Galacean Effects player multimedia plugin
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 云垣
|
|
6
|
-
* Version: v2.1.
|
|
7
|
-
*/function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@galacean/effects")):"function"==typeof define&&define.amd?define(["exports","@galacean/effects"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).ge=e.ge||{},e.ge.multimediaPlugin={}),e.ge)}(this,function(e,t){"use strict";var o=function(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach(function(o){if("default"!==o){var i=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,i.get?i:{enumerable:!0,get:function(){return e[o]}})}}),t.default=e,Object.freeze(t)}(t);function i(e,t,o,i,n,r,s){try{var a=e[r](s),u=a.value}catch(e){o(e);return}a.done?t(u):Promise.resolve(u).then(i,n)}function n(e){return function(){var t=this,o=arguments;return new Promise(function(n,r){var s=e.apply(t,o);function a(e){i(s,n,r,a,u,"next",e)}function u(e){i(s,n,r,a,u,"throw",e)}a(void 0)})}}function r(e,t){return(r=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function s(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&r(e,t)}function a(e,t,o,i){var n,r=arguments.length,s=r<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,o,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(r<3?n(s):r>3?n(t,o,s):n(t,o))||s);return r>3&&s&&Object.defineProperty(t,o,s),s}function u(e,t){var o,i,n,r,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return r={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function a(a){return function(u){return function(a){if(o)throw TypeError("Generator is already executing.");for(;r&&(r=0,a[0]&&(s=0)),s;)try{if(o=1,i&&(n=2&a[0]?i.return:a[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,a[1])).done)return n;switch(i=0,n&&(a=[2&a[0],n.value]),a[0]){case 0:case 1:n=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,i=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(n=(n=s.trys).length>0&&n[n.length-1])&&(6===a[0]||2===a[0])){s=0;continue}if(3===a[0]&&(!n||a[1]>n[0]&&a[1]<n[3])){s.label=a[1];break}if(6===a[0]&&s.label<n[1]){s.label=n[1],n=a;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(a);break}n[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],i=0}finally{o=n=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}function c(e,t,o){return(c=!function(){if("undefined"==typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}()?function(e,t,o){var i=[null];i.push.apply(i,t);var n=new(Function.bind.apply(e,i));return o&&r(n,o.prototype),n}:Reflect.construct).apply(null,arguments)}function A(e){return(A=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function d(e){var t="function"==typeof Map?new Map:void 0;return(d=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,o)}function o(){return c(e,arguments,A(this).constructor)}return o.prototype=Object.create(e.prototype,{constructor:{value:o,enumerable:!1,writable:!0,configurable:!0}}),r(o,e)})(e)}"function"==typeof SuppressedError&&SuppressedError;var l={2e3:"Autoplay permission for audio and video is not enabled"};function h(e,t,o){return p.apply(this,arguments)}function p(){return(p=n(function(e,o,i){var n;return u(this,function(r){return n=i.renderLevel,[2,Promise.all(e.map(function(i){if(t.passRenderLevel(i.renderLevel,n)){var r=new URL(i.url,location.href).href;if(o===t.spec.MultimediaType.video)return t.loadVideo(r);if(o===t.spec.MultimediaType.audio)return y(r)}throw Error("Invalid "+o+" source: "+JSON.stringify(e)+".")}))]})})).apply(this,arguments)}function f(){return(f=n(function(){var e;return u(this,function(t){switch(t.label){case 0:(e=document.createElement("audio")).src="data:audio/mpeg;base64,//uQxAACFCEW8uewc8Nfu50FhJuQAGAFJCAhaIHoMhfEnBzixrwNsCGGGmyeCECGGRKWwnB0MkzGh6Hn7JLEstwCADQsJwBAAAOOhOAGAcd0gJgTBuW7HBgJBgfvEgCAEBEiOyeTDxyiyjZLEsRDyEzMz+921nJyWJZn6w8P1769e/AYCQI6tIJAkGHL16zpxhY5VeYGCdd3/93d9w4tygIO/4IHBOD8Hz/4f+IDkEHU4n8PqBMMBCQ0iXWYFnCIGqooaZHfRqOrgxuOtjmpCJCaYjmQqDz3NJUBTFWK4soYEoCumIJzIBldNhLUmAaDzhggZmSAkr9SqAIjGJFGEMCQlIPKDMuo24qZIrKDONHWGqlZbOymMy2yhCoBQywFQAgBEsETW0hCoIkqQWBINPWa3rCoEg1MiBIEiZMUiklyMfKVqoUOxIkSMtVTMzOMSBiKJQMAiWyROrf/5mq//8mkknNBQlFjiJFHKqqr//1VV6qq3vNVVbJpFHXkijM+pIoy1VX7zPOJEkmJAJaYgpqKBgASEAAIAAAAAAAAAAAA//uSxAAD1p0iZiw9OIgAADSAAAAEYAwFApgokRqIFjigukAADJhFjIUGoGFlRAycQGC5QsJJRWdRZRVWZVNYBStcjsRuaiMSgmOQOvVAKBSBY4ygsJGDCEoUEWrE3NBfUyJSSTTiPMpDUUvrhTsC7XR/G6bx2nse52G+cjBDhQW5tan7IZREJY6ULlDpCIhCIhkPDYgFaN2//3JZVZVY6UXQO2NXV1u//P/KSqyqSai7GFdu0DEqoheCVpA1v///6qqaaaYRKqIGKpiCmooGABIQAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",e.muted=!0,e.crossOrigin="anonymous",t.label=1;case 1:return t.trys.push([1,3,,4]),[4,e.play()];case 2:return t.sent(),[3,4];case 3:throw t.sent(),new m(2e3,l[2e3]);case 4:return[2]}})})).apply(this,arguments)}function y(e){return v.apply(this,arguments)}function v(){return(v=n(function(e){var o,i;return u(this,function(n){switch(n.label){case 0:if(!window.AudioContext)return[3,5];n.label=1;case 1:return n.trys.push([1,4,,5]),o=new AudioContext,[4,t.loadBinary(e)];case 2:return i=n.sent(),[4,o.decodeAudioData(i)];case 3:return[2,n.sent()];case 4:throw n.sent(),Error("Failed to load audio from "+e+".");case 5:return[2,new Promise(function(t,o){var i=new Audio;"string"==typeof e?i.src=e:i.srcObject=e,i.muted=!1,i.addEventListener("canplaythrough",function(){t(i)}),i.addEventListener("error",function(){o(Error("Failed to load audio from "+i.src+"."))}),i.load()})]}})})).apply(this,arguments)}var m=function(e){function o(i,n){var r;return(r=e.call(this,n)||this).code=i,r.name=r.constructor.name,"captureStackTrace"in Error&&t.isFunction(Error.captureStackTrace)&&Error.captureStackTrace(function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(r),o),r}return s(o,e),o}(d(Error)),g=function(e){function o(){return e.apply(this,arguments)}return s(o,e),o.processAssets=function(e,o){return void 0===o&&(o={}),n(function(){var i,n,r;return u(this,function(s){switch(s.label){case 0:return[4,h(n=void 0===(i=e.videos)?[]:i,t.spec.MultimediaType.video,o)];case 1:return r=s.sent(),[2,{assets:n,loadedAssets:r}]}})})()},o}(t.AbstractPlugin),b=function(e){function o(){return e.apply(this,arguments)}return s(o,e),o.processAssets=function(e,o){return void 0===o&&(o={}),n(function(){var i,n,r;return u(this,function(s){switch(s.label){case 0:return[4,h(n=void 0===(i=e.audios)?[]:i,t.spec.MultimediaType.audio,o)];case 1:return r=s.sent(),[2,{assets:n,loadedAssets:r}]}})})()},o}(t.AbstractPlugin),C=0;e.VideoComponent=function(e){function o(o){var i;return(i=e.call(this,o)||this).threshold=.03,i.name="MVideo"+C++,i.geometry=i.createGeometry(t.glContext.TRIANGLES),i}s(o,e);var i=o.prototype;return i.setTexture=function(e){var t=this.renderer.texture,o=this.item.composition;o&&(o.textures.forEach(function(i,n){i===t&&(o.textures[n]=e)}),this.engine.removeTexture(t),this.renderer.texture=e,this.material.setTexture("_MainTex",e),this.video=e.source.video)},i.fromData=function(o){e.prototype.fromData.call(this,o);var i,n,r,s,a,u,c=o.interaction,A=o.options,d=o.listIndex,l=A.video,h=A.startColor,p=A.playbackRate,f=A.volume,y=A.muted,v=o.renderer;v||(v={}),l&&(this.video=l.data,this.setPlaybackRate(void 0===p?1:p),this.setVolume(void 0===f?1:f),this.setMuted(void 0!==y&&y),this.item.endBehavior===t.spec.EndBehavior.destroy&&this.setLoop(!1)),this.renderer={renderMode:null!=(i=v.renderMode)?i:t.spec.RenderMode.BILLBOARD,blending:null!=(n=v.blending)?n:t.spec.BlendingMode.ALPHA,texture:null!=(r=v.texture)?r:this.engine.emptyTexture,occlusion:!!v.occlusion,transparentOcclusion:!!v.transparentOcclusion||v.maskMode===t.spec.MaskMode.MASK,side:null!=(s=v.side)?s:t.spec.SideMode.DOUBLE,mask:null!=(a=v.mask)?a:0,maskMode:null!=(u=v.maskMode)?u:t.spec.MaskMode.NONE,order:void 0===d?0:d,shape:v.shape},this.interaction=c,this.pauseVideo(),this.renderInfo=t.getImageItemRenderInfo(this);var m=this.createGeometry(t.glContext.TRIANGLES),g=this.createMaterial(this.renderInfo,2);this.worldMatrix=t.math.Matrix4.fromIdentity(),this.material=g,this.geometry=m,this.material.setVector4("_Color",new t.math.Vector4().setFromArray(void 0===h?[1,1,1,1]:h)),this.material.setVector4("_TexOffset",new t.math.Vector4().setFromArray([0,0,1,1])),this.setItem()},i.onStart=function(){var t,o=this;e.prototype.onStart.call(this),null==(t=this.item.composition)||t.on("goto",function(e){e.time>0&&o.setCurrentTime(e.time)})},i.onUpdate=function(o){e.prototype.onUpdate.call(this,o);var i,n=this.item,r=n.time,s=n.duration,a=n.endBehavior;r>0&&(this.setVisible(!0),this.playVideo()),0===r&&(null==(i=this.item.composition)?void 0:i.rootItem.endBehavior)===t.spec.EndBehavior.freeze&&(this.pauseVideo(),this.setCurrentTime(0)),Math.abs(r-s)<this.threshold&&(a===t.spec.EndBehavior.freeze?this.pauseVideo():a===t.spec.EndBehavior.restart&&(this.setVisible(!1),this.pauseVideo(),this.setCurrentTime(0)))},i.getDuration=function(){return this.video?this.video.duration:0},i.getCurrentTime=function(){return this.video?this.video.currentTime:0},i.setThreshold=function(e){this.threshold=e},i.setCurrentTime=function(e){this.video&&(this.video.currentTime=e)},i.setLoop=function(e){this.video&&(this.video.loop=e)},i.setMuted=function(e){this.video&&this.video.muted!==e&&(this.video.muted=e)},i.setVolume=function(e){this.video&&this.video.volume!==e&&(this.video.volume=e)},i.setPlaybackRate=function(e){this.video&&this.video.playbackRate!==e&&(this.video.playbackRate=e)},i.playVideo=function(){var e=this;this.video&&this.video.play().catch(function(t){e.engine.renderErrors.add(t)})},i.pauseVideo=function(){this.video&&!this.video.paused&&this.video.pause()},i.onDestroy=function(){e.prototype.onDestroy.call(this),this.video&&(this.video.pause(),this.video.src="",this.video.load())},i.onDisable=function(){var t;e.prototype.onDisable.call(this),this.setCurrentTime(0),null==(t=this.video)||t.pause()},i.onEnable=function(){e.prototype.onEnable.call(this),this.playVideo()},o}(t.BaseRenderComponent),e.VideoComponent=a([t.effectsClass(t.spec.DataType.VideoComponent)],e.VideoComponent);var E=function(){function e(e,o){this.engine=o,this.audioSourceInfo={},this.isSupportAudioContext=!!window.AudioContext,this.options={endBehavior:t.spec.EndBehavior.destroy,duration:0},this.destroyed=!1,this.started=!1,this.initialized=!1,this.currentVolume=1,this.setAudioSource(e)}var o=e.prototype;return o.setAudioSource=function(e){if((this.audio||this.audioSourceInfo.source)&&this.dispose(),function e(t,o){return null!=o&&"undefined"!=typeof Symbol&&o[Symbol.hasInstance]?!!o[Symbol.hasInstance](t):e(t,o)}(e,AudioBuffer)){var t=new AudioContext,o=t.createGain();o.connect(t.destination);var i=t.createBufferSource();i.buffer=e,i.connect(o),this.audioSourceInfo={source:i,audioContext:t,gainNode:o}}else this.audio=e;this.started&&this.play()},o.getCurrentTime=function(){if(!this.isSupportAudioContext)return(null==(e=this.audio)?void 0:e.currentTime)||0;var e,t=this.audioSourceInfo.audioContext;return(null==t?void 0:t.currentTime)||0},o.play=function(){var e,o=this;if(this.isSupportAudioContext){var i=this.audioSourceInfo,n=i.audioContext,r=i.source;if(r&&n)switch(this.options.endBehavior){case t.spec.EndBehavior.destroy:case t.spec.EndBehavior.freeze:r.start(0);break;case t.spec.EndBehavior.restart:r.loop=!0,r.loopStart=0,r.loopEnd=this.options.duration,r.start(0)}this.started=!0}else null==(e=this.audio)||e.play().catch(function(e){o.engine.renderErrors.add(e)})},o.pause=function(){if(this.isSupportAudioContext){var e,t=this.audioSourceInfo,o=t.source,i=t.audioContext;i&&i.currentTime>0&&this.started&&(null==o||o.stop())}else null==(e=this.audio)||e.pause()},o.setVolume=function(e){if(this.isSupportAudioContext){var t=this.audioSourceInfo.gainNode;t&&(t.gain.value=e,this.currentVolume=e)}else this.audio&&(this.audio.volume=e,this.currentVolume=e)},o.setPlaybackRate=function(e){if(this.isSupportAudioContext){var t=this.audioSourceInfo.source;t&&(t.playbackRate.value=e)}else this.audio&&(this.audio.playbackRate=e)},o.setLoop=function(e){if(this.isSupportAudioContext){var t=this.audioSourceInfo.source;t?t.loop=e:this.engine.renderErrors.add(Error("Audio source is not found."))}else this.audio&&(this.audio.loop=e)},o.setOptions=function(e){this.initialized||(this.options=e,this.initialized=!0)},o.setMuted=function(e){if(this.isSupportAudioContext){var t=this.audioSourceInfo.gainNode,o=e?0:this.currentVolume;t&&(t.gain.value=o)}else this.audio&&(this.audio.muted=e)},o.dispose=function(){var e,t=this;if(!this.destroyed){if(this.isSupportAudioContext){var o=this.audioSourceInfo,i=o.audioContext,n=o.source;this.started&&(null==n||n.stop()),null==i||i.close().catch(function(e){t.engine.renderErrors.add(e)})}else null==(e=this.audio)||e.pause();this.destroyed=!0}},e}();e.AudioComponent=function(e){function o(){var t;return t=e.apply(this,arguments)||this,t.isVideoPlay=!1,t.threshold=.03,t}s(o,e);var i=o.prototype;return i.onUpdate=function(o){e.prototype.onUpdate.call(this,o);var i=this.item,n=i.time,r=i.duration,s=i.endBehavior;this.audioPlayer.setOptions({duration:r,endBehavior:s}),n>=0&&!this.isVideoPlay&&(this.audioPlayer.play(),this.isVideoPlay=!0),Math.abs(n-r)<this.threshold&&s===t.spec.EndBehavior.destroy&&this.audioPlayer.pause()},i.fromData=function(t){e.prototype.fromData.call(this,t);var o=t.options,i=o.playbackRate,n=o.muted,r=o.volume;this.audioPlayer=new E(o.audio.data,this.engine),this.audioPlayer.pause(),this.setPlaybackRate(void 0===i?1:i),this.setMuted(void 0!==n&&n),this.setVolume(void 0===r?1:r)},i.setAudioSource=function(e){this.audioPlayer.setAudioSource(e)},i.setVolume=function(e){this.audioPlayer.setVolume(e)},i.getCurrentTime=function(){return this.audioPlayer.getCurrentTime()},i.setMuted=function(e){this.audioPlayer.setMuted(e)},i.setLoop=function(e){this.audioPlayer.setLoop(e)},i.setPlaybackRate=function(e){this.audioPlayer.setPlaybackRate(e)},i.onDisable=function(){e.prototype.onDisable.call(this),this.audioPlayer.pause()},i.dispose=function(){e.prototype.dispose.call(this),this.audioPlayer.dispose()},o}(t.RendererComponent),e.AudioComponent=a([t.effectsClass(t.spec.DataType.AudioComponent)],e.AudioComponent);var M="2.1.3";t.registerPlugin("video",g,t.VFXItem,!0),t.registerPlugin("audio",b,t.VFXItem,!0),t.logger.info("Plugin multimedia version: "+M+"."),M!==o.version&&console.error("注意:请统一 Multimedia 插件与 Player 版本,不统一的版本混用会有不可预知的后果!","\nAttention: Please ensure the Multimedia plugin is synchronized with the Player version. Mixing and matching incompatible versions may result in unpredictable consequences!"),e.AudioPlayer=E,e.MultimediaError=m,e.checkAutoplayPermission=function(){return f.apply(this,arguments)},e.loadAudio=y,e.multimediaErrorDisplayMessageMap={2e3:"音视频自动播放权限未开启"},e.multimediaErrorMessageMap=l,e.processMultimedia=h,e.version=M,Object.defineProperty(e,"__esModule",{value:!0})});
|
|
6
|
+
* Version: v2.1.4
|
|
7
|
+
*/function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@galacean/effects")):"function"==typeof define&&define.amd?define(["exports","@galacean/effects"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).ge=e.ge||{},e.ge.multimediaPlugin={}),e.ge)}(this,function(e,t){"use strict";var o=function(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach(function(o){if("default"!==o){var i=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,i.get?i:{enumerable:!0,get:function(){return e[o]}})}}),t.default=e,Object.freeze(t)}(t);function i(e,t,o,i,n,r,s){try{var a=e[r](s),u=a.value}catch(e){o(e);return}a.done?t(u):Promise.resolve(u).then(i,n)}function n(e){return function(){var t=this,o=arguments;return new Promise(function(n,r){var s=e.apply(t,o);function a(e){i(s,n,r,a,u,"next",e)}function u(e){i(s,n,r,a,u,"throw",e)}a(void 0)})}}function r(e,t){return(r=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function s(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&r(e,t)}function a(e,t,o,i){var n,r=arguments.length,s=r<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,o,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(r<3?n(s):r>3?n(t,o,s):n(t,o))||s);return r>3&&s&&Object.defineProperty(t,o,s),s}function u(e,t){var o,i,n,r,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return r={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function a(a){return function(u){return function(a){if(o)throw TypeError("Generator is already executing.");for(;r&&(r=0,a[0]&&(s=0)),s;)try{if(o=1,i&&(n=2&a[0]?i.return:a[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,a[1])).done)return n;switch(i=0,n&&(a=[2&a[0],n.value]),a[0]){case 0:case 1:n=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,i=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(n=(n=s.trys).length>0&&n[n.length-1])&&(6===a[0]||2===a[0])){s=0;continue}if(3===a[0]&&(!n||a[1]>n[0]&&a[1]<n[3])){s.label=a[1];break}if(6===a[0]&&s.label<n[1]){s.label=n[1],n=a;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(a);break}n[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],i=0}finally{o=n=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}function c(e,t,o){return(c=!function(){if("undefined"==typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}()?function(e,t,o){var i=[null];i.push.apply(i,t);var n=new(Function.bind.apply(e,i));return o&&r(n,o.prototype),n}:Reflect.construct).apply(null,arguments)}function A(e){return(A=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function d(e){var t="function"==typeof Map?new Map:void 0;return(d=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,o)}function o(){return c(e,arguments,A(this).constructor)}return o.prototype=Object.create(e.prototype,{constructor:{value:o,enumerable:!1,writable:!0,configurable:!0}}),r(o,e)})(e)}"function"==typeof SuppressedError&&SuppressedError;var l={2e3:"Autoplay permission for audio and video is not enabled"};function h(e,t,o){return p.apply(this,arguments)}function p(){return(p=n(function(e,o,i){var n;return u(this,function(r){return n=i.renderLevel,[2,Promise.all(e.map(function(i){if(t.passRenderLevel(i.renderLevel,n)){var r=new URL(i.url,location.href).href;if(o===t.spec.MultimediaType.video)return t.loadVideo(r);if(o===t.spec.MultimediaType.audio)return y(r)}throw Error("Invalid "+o+" source: "+JSON.stringify(e)+".")}))]})})).apply(this,arguments)}function f(){return(f=n(function(){var e;return u(this,function(t){switch(t.label){case 0:(e=document.createElement("audio")).src="data:audio/mpeg;base64,//uQxAACFCEW8uewc8Nfu50FhJuQAGAFJCAhaIHoMhfEnBzixrwNsCGGGmyeCECGGRKWwnB0MkzGh6Hn7JLEstwCADQsJwBAAAOOhOAGAcd0gJgTBuW7HBgJBgfvEgCAEBEiOyeTDxyiyjZLEsRDyEzMz+921nJyWJZn6w8P1769e/AYCQI6tIJAkGHL16zpxhY5VeYGCdd3/93d9w4tygIO/4IHBOD8Hz/4f+IDkEHU4n8PqBMMBCQ0iXWYFnCIGqooaZHfRqOrgxuOtjmpCJCaYjmQqDz3NJUBTFWK4soYEoCumIJzIBldNhLUmAaDzhggZmSAkr9SqAIjGJFGEMCQlIPKDMuo24qZIrKDONHWGqlZbOymMy2yhCoBQywFQAgBEsETW0hCoIkqQWBINPWa3rCoEg1MiBIEiZMUiklyMfKVqoUOxIkSMtVTMzOMSBiKJQMAiWyROrf/5mq//8mkknNBQlFjiJFHKqqr//1VV6qq3vNVVbJpFHXkijM+pIoy1VX7zPOJEkmJAJaYgpqKBgASEAAIAAAAAAAAAAAA//uSxAAD1p0iZiw9OIgAADSAAAAEYAwFApgokRqIFjigukAADJhFjIUGoGFlRAycQGC5QsJJRWdRZRVWZVNYBStcjsRuaiMSgmOQOvVAKBSBY4ygsJGDCEoUEWrE3NBfUyJSSTTiPMpDUUvrhTsC7XR/G6bx2nse52G+cjBDhQW5tan7IZREJY6ULlDpCIhCIhkPDYgFaN2//3JZVZVY6UXQO2NXV1u//P/KSqyqSai7GFdu0DEqoheCVpA1v///6qqaaaYRKqIGKpiCmooGABIQAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",e.muted=!0,e.crossOrigin="anonymous",t.label=1;case 1:return t.trys.push([1,3,,4]),[4,e.play()];case 2:return t.sent(),[3,4];case 3:throw t.sent(),new m(2e3,l[2e3]);case 4:return[2]}})})).apply(this,arguments)}function y(e){return v.apply(this,arguments)}function v(){return(v=n(function(e){var o,i;return u(this,function(n){switch(n.label){case 0:if(!window.AudioContext)return[3,5];n.label=1;case 1:return n.trys.push([1,4,,5]),o=new AudioContext,[4,t.loadBinary(e)];case 2:return i=n.sent(),[4,o.decodeAudioData(i)];case 3:return[2,n.sent()];case 4:throw n.sent(),Error("Failed to load audio from "+e+".");case 5:return[2,new Promise(function(t,o){var i=new Audio;"string"==typeof e?i.src=e:i.srcObject=e,i.muted=!1,i.addEventListener("canplaythrough",function(){t(i)}),i.addEventListener("error",function(){o(Error("Failed to load audio from "+i.src+"."))}),i.load()})]}})})).apply(this,arguments)}var m=function(e){function o(i,n){var r;return(r=e.call(this,n)||this).code=i,r.name=r.constructor.name,"captureStackTrace"in Error&&t.isFunction(Error.captureStackTrace)&&Error.captureStackTrace(function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(r),o),r}return s(o,e),o}(d(Error)),g=function(e){function o(){return e.apply(this,arguments)}return s(o,e),o.processAssets=function(e,o){return void 0===o&&(o={}),n(function(){var i,n,r;return u(this,function(s){switch(s.label){case 0:return[4,h(n=void 0===(i=e.videos)?[]:i,t.spec.MultimediaType.video,o)];case 1:return r=s.sent(),[2,{assets:n,loadedAssets:r}]}})})()},o}(t.AbstractPlugin),b=function(e){function o(){return e.apply(this,arguments)}return s(o,e),o.processAssets=function(e,o){return void 0===o&&(o={}),n(function(){var i,n,r;return u(this,function(s){switch(s.label){case 0:return[4,h(n=void 0===(i=e.audios)?[]:i,t.spec.MultimediaType.audio,o)];case 1:return r=s.sent(),[2,{assets:n,loadedAssets:r}]}})})()},o}(t.AbstractPlugin),C=0;e.VideoComponent=function(e){function o(o){var i;return(i=e.call(this,o)||this).threshold=.03,i.name="MVideo"+C++,i.geometry=i.createGeometry(t.glContext.TRIANGLES),i}s(o,e);var i=o.prototype;return i.setTexture=function(e){var t=this.renderer.texture,o=this.item.composition;o&&(o.textures.forEach(function(i,n){i===t&&(o.textures[n]=e)}),this.engine.removeTexture(t),this.renderer.texture=e,this.material.setTexture("_MainTex",e),this.video=e.source.video)},i.fromData=function(o){e.prototype.fromData.call(this,o);var i,n,r,s,a,u,c=o.interaction,A=o.options,d=o.listIndex,l=A.video,h=A.startColor,p=A.playbackRate,f=A.volume,y=A.muted,v=o.renderer;v||(v={}),l&&(this.video=l.data,this.setPlaybackRate(void 0===p?1:p),this.setVolume(void 0===f?1:f),this.setMuted(void 0!==y&&y),this.item.endBehavior===t.spec.EndBehavior.destroy&&this.setLoop(!1)),this.renderer={renderMode:null!=(i=v.renderMode)?i:t.spec.RenderMode.BILLBOARD,blending:null!=(n=v.blending)?n:t.spec.BlendingMode.ALPHA,texture:null!=(r=v.texture)?r:this.engine.emptyTexture,occlusion:!!v.occlusion,transparentOcclusion:!!v.transparentOcclusion||v.maskMode===t.spec.MaskMode.MASK,side:null!=(s=v.side)?s:t.spec.SideMode.DOUBLE,mask:null!=(a=v.mask)?a:0,maskMode:null!=(u=v.maskMode)?u:t.spec.MaskMode.NONE,order:void 0===d?0:d,shape:v.shape},this.interaction=c,this.pauseVideo(),this.renderInfo=t.getImageItemRenderInfo(this);var m=this.createGeometry(t.glContext.TRIANGLES),g=this.createMaterial(this.renderInfo,2);this.worldMatrix=t.math.Matrix4.fromIdentity(),this.material=g,this.geometry=m,this.material.setVector4("_Color",new t.math.Vector4().setFromArray(void 0===h?[1,1,1,1]:h)),this.material.setVector4("_TexOffset",new t.math.Vector4().setFromArray([0,0,1,1])),this.setItem()},i.onStart=function(){var t,o=this;e.prototype.onStart.call(this),null==(t=this.item.composition)||t.on("goto",function(e){e.time>0&&o.setCurrentTime(e.time)})},i.onUpdate=function(o){e.prototype.onUpdate.call(this,o);var i,n=this.item,r=n.time,s=n.duration,a=n.endBehavior;r>0&&(this.setVisible(!0),this.playVideo()),0===r&&(null==(i=this.item.composition)?void 0:i.rootItem.endBehavior)===t.spec.EndBehavior.freeze&&(this.pauseVideo(),this.setCurrentTime(0)),Math.abs(r-s)<this.threshold&&(a===t.spec.EndBehavior.freeze?this.pauseVideo():a===t.spec.EndBehavior.restart&&(this.setVisible(!1),this.pauseVideo(),this.setCurrentTime(0)))},i.getDuration=function(){return this.video?this.video.duration:0},i.getCurrentTime=function(){return this.video?this.video.currentTime:0},i.setThreshold=function(e){this.threshold=e},i.setCurrentTime=function(e){this.video&&(this.video.currentTime=e)},i.setLoop=function(e){this.video&&(this.video.loop=e)},i.setMuted=function(e){this.video&&this.video.muted!==e&&(this.video.muted=e)},i.setVolume=function(e){this.video&&this.video.volume!==e&&(this.video.volume=e)},i.setPlaybackRate=function(e){this.video&&this.video.playbackRate!==e&&(this.video.playbackRate=e)},i.playVideo=function(){var e=this;this.video&&this.video.play().catch(function(t){e.engine.renderErrors.add(t)})},i.pauseVideo=function(){this.video&&!this.video.paused&&this.video.pause()},i.onDestroy=function(){e.prototype.onDestroy.call(this),this.video&&(this.video.pause(),this.video.src="",this.video.load())},i.onDisable=function(){var t;e.prototype.onDisable.call(this),this.setCurrentTime(0),null==(t=this.video)||t.pause()},i.onEnable=function(){e.prototype.onEnable.call(this),this.playVideo()},o}(t.BaseRenderComponent),e.VideoComponent=a([t.effectsClass(t.spec.DataType.VideoComponent)],e.VideoComponent);var E=function(){function e(e,o){this.engine=o,this.audioSourceInfo={},this.isSupportAudioContext=!!window.AudioContext,this.options={endBehavior:t.spec.EndBehavior.destroy,duration:0},this.destroyed=!1,this.started=!1,this.initialized=!1,this.currentVolume=1,this.setAudioSource(e)}var o=e.prototype;return o.setAudioSource=function(e){if((this.audio||this.audioSourceInfo.source)&&this.dispose(),function e(t,o){return null!=o&&"undefined"!=typeof Symbol&&o[Symbol.hasInstance]?!!o[Symbol.hasInstance](t):e(t,o)}(e,AudioBuffer)){var t=new AudioContext,o=t.createGain();o.connect(t.destination);var i=t.createBufferSource();i.buffer=e,i.connect(o),this.audioSourceInfo={source:i,audioContext:t,gainNode:o}}else this.audio=e;this.started&&this.play()},o.getCurrentTime=function(){if(!this.isSupportAudioContext)return(null==(e=this.audio)?void 0:e.currentTime)||0;var e,t=this.audioSourceInfo.audioContext;return(null==t?void 0:t.currentTime)||0},o.play=function(){var e,o=this;if(this.isSupportAudioContext){var i=this.audioSourceInfo,n=i.audioContext,r=i.source;if(r&&n)switch(this.options.endBehavior){case t.spec.EndBehavior.destroy:case t.spec.EndBehavior.freeze:r.start(0);break;case t.spec.EndBehavior.restart:r.loop=!0,r.loopStart=0,r.loopEnd=this.options.duration,r.start(0)}this.started=!0}else null==(e=this.audio)||e.play().catch(function(e){o.engine.renderErrors.add(e)})},o.pause=function(){if(this.isSupportAudioContext){var e,t=this.audioSourceInfo,o=t.source,i=t.audioContext;i&&i.currentTime>0&&this.started&&(null==o||o.stop())}else null==(e=this.audio)||e.pause()},o.setVolume=function(e){if(this.isSupportAudioContext){var t=this.audioSourceInfo.gainNode;t&&(t.gain.value=e,this.currentVolume=e)}else this.audio&&(this.audio.volume=e,this.currentVolume=e)},o.setPlaybackRate=function(e){if(this.isSupportAudioContext){var t=this.audioSourceInfo.source;t&&(t.playbackRate.value=e)}else this.audio&&(this.audio.playbackRate=e)},o.setLoop=function(e){if(this.isSupportAudioContext){var t=this.audioSourceInfo.source;t?t.loop=e:this.engine.renderErrors.add(Error("Audio source is not found."))}else this.audio&&(this.audio.loop=e)},o.setOptions=function(e){this.initialized||(this.options=e,this.initialized=!0)},o.setMuted=function(e){if(this.isSupportAudioContext){var t=this.audioSourceInfo.gainNode,o=e?0:this.currentVolume;t&&(t.gain.value=o)}else this.audio&&(this.audio.muted=e)},o.dispose=function(){var e,t=this;if(!this.destroyed){if(this.isSupportAudioContext){var o=this.audioSourceInfo,i=o.audioContext,n=o.source;this.started&&(null==n||n.stop()),null==i||i.close().catch(function(e){t.engine.renderErrors.add(e)})}else null==(e=this.audio)||e.pause();this.destroyed=!0}},e}();e.AudioComponent=function(e){function o(){var t;return t=e.apply(this,arguments)||this,t.isVideoPlay=!1,t.threshold=.03,t}s(o,e);var i=o.prototype;return i.onUpdate=function(o){e.prototype.onUpdate.call(this,o);var i=this.item,n=i.time,r=i.duration,s=i.endBehavior;this.audioPlayer.setOptions({duration:r,endBehavior:s}),n>=0&&!this.isVideoPlay&&(this.audioPlayer.play(),this.isVideoPlay=!0),Math.abs(n-r)<this.threshold&&s===t.spec.EndBehavior.destroy&&this.audioPlayer.pause()},i.fromData=function(t){e.prototype.fromData.call(this,t);var o=t.options,i=o.playbackRate,n=o.muted,r=o.volume;this.audioPlayer=new E(o.audio.data,this.engine),this.audioPlayer.pause(),this.setPlaybackRate(void 0===i?1:i),this.setMuted(void 0!==n&&n),this.setVolume(void 0===r?1:r)},i.setAudioSource=function(e){this.audioPlayer.setAudioSource(e)},i.setVolume=function(e){this.audioPlayer.setVolume(e)},i.getCurrentTime=function(){return this.audioPlayer.getCurrentTime()},i.setMuted=function(e){this.audioPlayer.setMuted(e)},i.setLoop=function(e){this.audioPlayer.setLoop(e)},i.setPlaybackRate=function(e){this.audioPlayer.setPlaybackRate(e)},i.onDisable=function(){e.prototype.onDisable.call(this),this.audioPlayer.pause()},i.dispose=function(){e.prototype.dispose.call(this),this.audioPlayer.dispose()},o}(t.RendererComponent),e.AudioComponent=a([t.effectsClass(t.spec.DataType.AudioComponent)],e.AudioComponent);var M="2.1.4";t.registerPlugin("video",g,t.VFXItem,!0),t.registerPlugin("audio",b,t.VFXItem,!0),t.logger.info("Plugin multimedia version: "+M+"."),M!==o.version&&console.error("注意:请统一 Multimedia 插件与 Player 版本,不统一的版本混用会有不可预知的后果!","\nAttention: Please ensure the Multimedia plugin is synchronized with the Player version. Mixing and matching incompatible versions may result in unpredictable consequences!"),e.AudioPlayer=E,e.MultimediaError=m,e.checkAutoplayPermission=function(){return f.apply(this,arguments)},e.loadAudio=y,e.multimediaErrorDisplayMessageMap={2e3:"音视频自动播放权限未开启"},e.multimediaErrorMessageMap=l,e.processMultimedia=h,e.version=M,Object.defineProperty(e,"__esModule",{value:!0})});
|
|
8
8
|
//# sourceMappingURL=index.min.js.map
|
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Description: Galacean Effects player multimedia plugin
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 云垣
|
|
6
|
-
* Version: v2.1.
|
|
6
|
+
* Version: v2.1.4
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import * as EFFECTS from '@galacean/effects';
|
|
@@ -951,7 +951,7 @@ AudioComponent = __decorate([
|
|
|
951
951
|
|
|
952
952
|
/**
|
|
953
953
|
* 插件版本号
|
|
954
|
-
*/ var version = "2.1.
|
|
954
|
+
*/ var version = "2.1.4";
|
|
955
955
|
registerPlugin("video", VideoLoader, VFXItem, true);
|
|
956
956
|
registerPlugin("audio", AudioLoader, VFXItem, true);
|
|
957
957
|
logger.info("Plugin multimedia version: " + version + ".");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@galacean/effects-plugin-multimedia",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.4",
|
|
4
4
|
"description": "Galacean Effects player multimedia plugin",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"registry": "https://registry.npmjs.org"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@galacean/effects": "2.1.
|
|
31
|
+
"@galacean/effects": "2.1.4"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
34
|
"dev": "vite",
|