mirror of
https://github.com/VickScarlet/lifeRestart.git
synced 2025-07-14 16:22:38 +08:00
1 line
24 KiB
JavaScript
1 line
24 KiB
JavaScript
!function(n,a){a.un,a.uns;var i=a.static,t=a.class,o=a.getset,d=(a.__newvec,laya.utils.Browser),e=a.Config,l=(laya.events.Event,laya.events.EventDispatcher),s=laya.resource.HTMLImage,h=laya.utils.Handler,r=laya.display.Input,p=laya.net.Loader,u=laya.net.LocalStorage,c=(laya.maths.Matrix,laya.renders.Render),v=laya.net.ResourceVersion,f=laya.utils.RunDriver,m=laya.media.SoundChannel,y=laya.media.SoundManager,_=laya.net.URL,g=laya.utils.Utils,w=(t(E,"laya.tbplugin.mini.MiniFileMgr",null,"MiniFileMgr$11"),E.isLocalNativeFile=function(i){for(var e=0,n=x.nativefiles.length;e<n;e++)if(-1!=i.indexOf(x.nativefiles[e]))return!0;return!1},E.getFileInfo=function(i){i=E.fakeObj[i];return null==i?null:i},E.read=function(i,e,n,t,o,a){void 0===e&&(e="utf8"),void 0===o&&(o=!1),void 0===a&&(a=""),i=""==(t=void 0===t?"":t)||-1==t.indexOf("http://")&&-1==t.indexOf("https://")?i:E.getFileNativePath(i),E.fs.readFile({filePath:i,encoding:e,success:function(i){null!=n&&n.runWith([0,i])},fail:function(i){i&&""!=t?E.downFiles(t,e,n,t,o,a):null!=n&&n.runWith([1])}})},E.downFiles=function(e,n,t,o,a,l,s){void 0===n&&(n="utf8"),void 0===o&&(o=""),void 0===a&&(a=!1),void 0===l&&(l=""),void 0===s&&(s=!0);E.wxdown({url:e,success:function(i){i.hasOwnProperty("statusCode")||(i.statusCode=200),200===i.statusCode?E.readFile(i.apFilePath,n,t,o,a,l,s):403===i.statusCode?null!=t&&t.runWith([0,e]):null!=t&&t.runWith([1,i])},fail:function(i){null!=t&&t.runWith([1,i])}})},E.readFile=function(e,n,t,o,a,i,l){void 0===o&&(o=""),void 0===a&&(a=!1),void 0===i&&(i=""),void 0===l&&(l=!0),E.fs.readFile({filePath:e,encoding:n=void 0===n?"utf8":n,success:function(i){(-1!=e.indexOf("http://")||-1!=e.indexOf("https://"))&&a?(null!=t&&t.runWith([0,i]),E.copyFile(e,o,null,n,l)):null!=t&&t.runWith([0,i])},fail:function(i){i&&null!=t&&t.runWith([1,i])}})},E.downOtherFiles=function(i,e,n,t,o){void 0===n&&(n=""),void 0===t&&(t=!1),void 0===o&&(o=!0),E.wxdown({url:i,success:function(i){i.hasOwnProperty("statusCode")||(i.statusCode=200),200===i.statusCode?t&&-1==n.indexOf(".php")?(null!=e&&e.runWith([0,i.apFilePath]),E.copyFile(i.apFilePath,n,null,"",o)):null!=e&&e.runWith([0,i.apFilePath]):null!=e&&e.runWith([1,i])},fail:function(i){null!=e&&e.runWith([1,i])}})},E.downLoadFile=function(i,e,n,t,o){void 0===e&&(e=""),void 0===t&&(t="utf8"),void 0===o&&(o=!1),d.window.hasOwnProperty("my")?a.loader.load(i,n):"image"==e||"sound"==e?E.downOtherFiles(i,n,i,o,!1):E.downFiles(i,t,n,i,!0,e,o)},E.copyFile=function(n,t,o,a,l){void 0===a&&(a=""),void 0===l&&(l=!0);var i=n.split("/"),s=i[i.length-1],i=E.getFileInfo(t),r=E.getFileNativePath(s);E.fakeObj[t]={md5:s,readyUrl:t,size:0,times:d.now(),encoding:a};var u=E.getCacheUseSize();i?i.readyUrl!=t?E.fs.getFileInfo({filePath:n,success:function(i){l&&52428800<=u+4194304+i.size&&(i.size>x.minClearSize&&(x.minClearSize=i.size),E.onClearCacheRes()),E.deleteFile(n,t,o,a,i.size)},fail:function(i){null!=o&&o.runWith([1,i])}}):null!=o&&o.runWith([0]):E.fs.getFileInfo({filePath:n,success:function(e){l&&52428800<=u+4194304+e.size&&(e.size>x.minClearSize&&(x.minClearSize=e.size),E.onClearCacheRes()),E.fs.copyFile({srcPath:n,destPath:r,success:function(i){E.onSaveFile(t,s,!0,a,o,e.size)},fail:function(i){null!=o&&o.runWith([1,i])}})},fail:function(i){null!=o&&o.runWith([1,i])}})},E.onClearCacheRes=function(){var i,e=x.minClearSize,n=[];for(i in E.filesListObj)"fileUsedSize"!=i&&n.push(E.filesListObj[i]);E.sortOn(n,"times",16);for(var t=0,o=1,a=n.length;o<a;o++){var l=n[o];if(e<=t)break;t+=l.size,E.deleteFile("",l.readyUrl)}},E.sortOn=function(i,n,e){return 16==(e=void 0===e?0:e)?i.sort(function(i,e){return i[n]-e[n]}):18==e?i.sort(function(i,e){return e[n]-i[n]}):i.sort(function(i,e){return i[n]-e[n]})},E.getFileNativePath=function(i){return laya.tbplugin.mini.MiniFileMgr.fileNativeDir+"/"+i},E.deleteFile=function(t,o,a,l,s){void 0===l&&(l=""),void 0===s&&(s=0);var i=E.getFileInfo(o=void 0===o?"":o),i=E.getFileNativePath(i.md5);E.fs.unlink({filePath:i,success:function(i){var e,n=""!=t;""!=t?(e=E.getFileNativePath(t),E.fs.copyFile({srcPath:t,destPath:e,success:function(i){E.onSaveFile(o,t,n,l,a,i.size)},fail:function(i){null!=a&&a.runWith([1,i])}})):E.onSaveFile(o,t,n,l,a,s)},fail:function(i){}})},E.deleteAll=function(){var i,e=[];for(i in E.filesListObj)"fileUsedSize"!=i&&e.push(E.filesListObj[i]);for(var n=1,t=e.length;n<t;n++){var o=e[n];E.deleteFile("",o.readyUrl)}laya.tbplugin.mini.MiniFileMgr.filesListObj&&laya.tbplugin.mini.MiniFileMgr.filesListObj.fileUsedSize&&(laya.tbplugin.mini.MiniFileMgr.filesListObj.fileUsedSize=0),laya.tbplugin.mini.MiniFileMgr.writeFilesList("",JSON.stringify({}),!1)},E.onSaveFile=function(i,e,n,t,o,a){void 0===n&&(n=!0),void 0===t&&(t=""),void 0===a&&(a=0);var l=i;null==E.filesListObj.fileUsedSize&&(E.filesListObj.fileUsedSize=0),n?(E.getFileNativePath(e),E.filesListObj[l]={md5:e,readyUrl:i,size:a,times:d.now(),encoding:t},E.filesListObj.fileUsedSize=parseInt(E.filesListObj.fileUsedSize)+a,E.writeFilesList(l,JSON.stringify(E.filesListObj),!0),null!=o&&o.runWith([0])):E.filesListObj[l]&&(a=parseInt(E.filesListObj[l].size),E.filesListObj.fileUsedSize=parseInt(E.filesListObj.fileUsedSize)-a,E.filesListObj[l].md5==E.fakeObj[l].md5&&delete E.fakeObj[l],delete E.filesListObj[l],E.writeFilesList(l,JSON.stringify(E.filesListObj),!1),null!=o&&o.runWith([0]))},E.writeFilesList=function(i,e,n){E.fs.writeFile({filePath:E.fileNativeDir+"/"+E.fileListName,encoding:"utf8",data:e,success:function(i){},fail:function(i){}}),!x.isZiYu&&x.isPosMsgYu&&x.window.my.postMessage&&x.window.my.postMessage({url:i,data:E.filesListObj[i],isLoad:"filenative",isAdd:n})},E.getCacheUseSize=function(){return E.filesListObj&&E.filesListObj.fileUsedSize?E.filesListObj.fileUsedSize:0},E.existDir=function(i,e){E.fs.mkdir({dirPath:i,success:function(i){null!=e&&e.runWith([0,{data:JSON.stringify({})}])},fail:function(i){10025==i.error?E.readSync(E.fileListName,"utf8",e):null!=e&&e.runWith([1,i])}})},E.readSync=function(i,e,n,t){void 0===e&&(e="utf8"),void 0===t&&(t="");var o,i=E.getFileNativePath(i);try{E.fs.readFile({filePath:i,encoding:e,success:function(i){o=i.data,null!=n&&n.runWith([0,{data:o}])},fail:function(){null!=n&&n.runWith([1])}})}catch(i){null!=n&&n.runWith([1])}},E.setNativeFileDir=function(i){E.fileNativeDir=x.window.my.env.USER_DATA_PATH+i},E.filesListObj={},E.fakeObj={},E.fileNativeDir=null,E.fileListName="layaairfiles.txt",E.ziyuFileData={},E.ziyuFileTextureData={},E.loadPath="",E.DESCENDING=2,E.NUMERIC=16,i(E,["fs",function(){return this.fs=x.window.my.getFileSystemManager()},"wxdown",function(){return this.wxdown=x.window.my.downloadFile}]),E);function E(){}var F=(t(C,"laya.tbplugin.mini.MiniImage",null,"MiniImage$11"),C.prototype._loadImage=function(i){var e,n;i=_.formatURL(i),w.isLocalNativeFile(i)||-1==i.indexOf("http://")&&-1==i.indexOf("https://")?-1!=i.indexOf(x.window.my.env.USER_DATA_PATH)?C.onCreateImage(i,this,!1,i):(i=""!=w.loadPath?i.split(w.loadPath)[1]:(n=i,(i=""!=(e=""!=_.rootPath?_.rootPath:_.basePath)?i.split(e)[1]:i)||n),C.onCreateImage(i,this,!0)):C.onCreateImage(i,this,!1,encodeURI(i))},C.onCreateImage=function(e,n,i,t){var o,a;function l(){a.onload=null,a.onerror=null,delete n.imgCache[e]}void 0===t&&(t=""),o=(i=void 0===i?!1:i)?x.baseDir+e:""!=t?t:e,null==n.imgCache&&(n.imgCache={});i=function(){l(),n.onLoaded(a)},t=function(){l(),delete w.filesListObj[e],delete w.fakeObj[e],n.event("error","Load image failed")};"nativeimage"==n._type?((a=new d.window.Image).crossOrigin="",a.onload=i,a.onerror=t,a.src=o,n.imgCache[e]=a):new s.create(o,{onload:i,onerror:t,onCreate:function(i){a=i,n.imgCache[e]=i}})},C);function C(){}var b=(t(L,"laya.tbplugin.mini.MiniInput",null,"MiniInput$11"),L._createInputElement=function(){r._initInput(r.area=d.createElement("textarea")),r._initInput(r.input=d.createElement("input")),r.inputContainer=d.createElement("div"),r.inputContainer.style.position="absolute",r.inputContainer.style.zIndex=1e5,d.container.appendChild(r.inputContainer),r.inputContainer.setPos=function(i,e){r.inputContainer.style.left=i+"px",r.inputContainer.style.top=e+"px"},y._soundClass=D,y._musicClass=D;var i=x.systemInfo.model,e=x.systemInfo.system;-1!=i.indexOf("iPhone")&&(d.onIPhone=!0,d.onIOS=!0,d.onIPad=!0,d.onAndroid=!1),-1==e.indexOf("Android")&&-1==e.indexOf("Adr")||(d.onAndroid=!0,d.onIPhone=!1,d.onIOS=!1,d.onIPad=!1)},L._onStageResize=function(){a.stage._canvasTransform.identity().scale(d.width/c.canvas.width/f.getPixelRatio(),d.height/c.canvas.height/f.getPixelRatio())},L.wxinputFocus=function(i){},L.inputEnter=function(i){},L.wxinputblur=function(){},L.hideKeyboard=function(){},L);function L(){}var S=(t(O,"laya.tbplugin.mini.MiniLocalStorage",null,"MiniLocalStorage$10"),O.__init__=function(){O.items=O},O.setItem=function(e,n){try{x.window.my.setStorageSync({key:e,data:n})}catch(i){x.window.my.setStorage({key:e,data:n})}},O.getItem=function(i){i=x.window.my.getStorageSync({key:i});return i.success?i.data:null},O.setJSON=function(i,e){O.setItem(i,e)},O.getJSON=function(i){return O.getItem(i)},O.removeItem=function(i){x.window.my.removeStorageSync(i)},O.clear=function(){x.window.my.clearStorageSync()},O.getStorageInfoSync=function(){try{var i=x.window.my.getStorageInfoSync();return console.log(i.keys),console.log(i.currentSize),console.log(i.limitSize),i}catch(i){}return null},O.support=!0,O.items=null,O);function O(){}t(P,"laya.tbplugin.mini.MiniLocation",null,"MiniLocation$11"),P.__init__=function(){x.window.navigator.geolocation.getCurrentPosition=P.getCurrentPosition,x.window.navigator.geolocation.watchPosition=P.watchPosition,x.window.navigator.geolocation.clearWatch=P.clearWatch},P.getCurrentPosition=function(e,i,n){var t;(t={success:function(i){null!=e&&e(i)}}).fail=i,x.window.my.getLocation(t)},P.watchPosition=function(i,e,n){var t;return P._curID++,(t={}).success=i,t.error=e,P._watchDic[P._curID]=t,a.timer.loop(1e3,null,P._myLoop),P._curID},P.clearWatch=function(i){delete P._watchDic[i],P._hasWatch()||a.timer.clear(null,P._myLoop)},P._hasWatch=function(){for(var i in P._watchDic)if(P._watchDic[i])return!0;return!1},P._myLoop=function(){P.getCurrentPosition(P._mySuccess,P._myError)},P._mySuccess=function(i){var e,n={};for(e in n.coords=i,n.timestamp=d.now(),P._watchDic)P._watchDic[e].success&&P._watchDic[e].success(n)},P._myError=function(i){for(var e in P._watchDic)P._watchDic[e].error&&P._watchDic[e].error(i)},P._watchDic={},P._curID=0;function P(){}!function(){function i(i,e){this.videoend=!1,this.videourl="",this.videoElement=null,this.onPlayFunc=null,this.onEndedFunC=null,this._duration=NaN,this.position=NaN,this.videoElement=x.window.my.createVideo({width:i=void 0===i?320:i,height:e=void 0===e?240:e,autoplay:!0})}t(i,"laya.tbplugin.mini.MiniVideo",null,"MiniVideo$9");var e=i.prototype;e.on=function(i,e,n){"loadedmetadata"==i?(this.onPlayFunc=n.bind(e),this.videoElement.onPlay=this.onPlayFunction.bind(this)):"ended"==i&&(this.onEndedFunC=n.bind(e),this.videoElement.onEnded=this.onEndedFunction.bind(this)),this.videoElement.onTimeUpdate=this.onTimeUpdateFunc.bind(this)},e.onTimeUpdateFunc=function(i){this.position=i.position,this._duration=i.duration},e.onPlayFunction=function(){this.videoElement&&(this.videoElement.readyState=200),console.log("=====视频加载完成========"),null!=this.onPlayFunc&&this.onPlayFunc()},e.onEndedFunction=function(){this.videoElement&&(this.videoend=!0,console.log("=====视频播放完毕========"),null!=this.onEndedFunC&&this.onEndedFunC())},e.off=function(i,e,n){"loadedmetadata"==i?(this.onPlayFunc=n.bind(e),this.videoElement.offPlay=this.onPlayFunction.bind(this)):"ended"==i&&(this.onEndedFunC=n.bind(e),this.videoElement.offEnded=this.onEndedFunction.bind(this))},e.load=function(i){this.videoElement&&(this.videoElement.src=i)},e.play=function(){this.videoElement&&(this.videoend=!1,this.videoElement.play())},e.pause=function(){this.videoElement&&(this.videoend=!0,this.videoElement.pause())},e.size=function(i,e){this.videoElement&&(this.videoElement.width=i,this.videoElement.height=e)},e.destroy=function(){this.videoElement&&this.videoElement.destroy(),this.videoElement=null,this.onEndedFunC=null,this.onPlayFunc=null,this.videoend=!1,this.videourl=null},e.reload=function(){this.videoElement&&(this.videoElement.src=this.videourl)},o(0,e,"duration",function(){return this._duration}),o(0,e,"paused",function(){return!!this.videoElement&&this.videoElement.paused}),o(0,e,"loop",function(){return!!this.videoElement&&this.videoElement.loop},function(i){this.videoElement&&(this.videoElement.loop=i)}),o(0,e,"currentTime",function(){return this.videoElement?this.videoElement.initialTime:0},function(i){this.videoElement&&(this.videoElement.initialTime=i)}),o(0,e,"ended",function(){return this.videoend}),o(0,e,"muted",function(){return!!this.videoElement&&this.videoElement.muted},function(i){this.videoElement&&(this.videoElement.muted=i)}),o(0,e,"videoWidth",function(){return this.videoElement?this.videoElement.width:0}),o(0,e,"videoHeight",function(){return this.videoElement?this.videoElement.height:0}),o(0,e,"playbackRate",function(){return this.videoElement?this.videoElement.playbackRate:0},function(i){this.videoElement&&(this.videoElement.playbackRate=i)}),o(0,e,"x",function(){return this.videoElement?this.videoElement.x:0},function(i){this.videoElement&&(this.videoElement.x=i)}),o(0,e,"y",function(){return this.videoElement?this.videoElement.y:0},function(i){this.videoElement&&(this.videoElement.y=i)}),o(0,e,"currentSrc",function(){return this.videoElement.src}),i.__init__=function(){laya.device.media.Video=i}}();var x=(t(I,"laya.tbplugin.mini.TBPluginAdapter"),I.getJson=function(i){return JSON.parse(i)},I.init=function(){var i;I._inited||(I._inited=!0,(-1<(i=(I.window=n).navigator.userAgent).indexOf("TB")||-1<i.indexOf("Taobao")||-1<i.indexOf("TM/"))&&(I.EnvConfig={},w.setNativeFileDir("/layaairGame"),w.existDir(w.fileNativeDir,h.create(I,I.onMkdirCallBack)),I.systemInfo=I.window.my.getSystemInfoSync(),I.window.focus=function(){},a._getUrlPath=function(){},a.getUrlPath=function(){},I.window.logtime=function(i){},I.window.alertTimeLog=function(i){},I.window.resetShareInfo=function(){},I._preCreateElement=d.createElement,d.createElement=I.createElement,I.window.CanvasRenderingContext2D=function(){},I.window.CanvasRenderingContext2D.prototype=I._preCreateElement("canvas").getContext("2d").__proto__,I.window.document.body.appendChild=function(){},f.createShaderCondition=I.createShaderCondition,g.parseXMLFromString=I.parseXMLFromString,r._createInputElement=b._createInputElement,I.EnvConfig.load=p.prototype.load,p.prototype.load=M.prototype.load,p.prototype._loadImage=F.prototype._loadImage,(u._baseClass=S).__init__(),e.useRetinalCanvas=!0))},I.measureText=function(i){i=I._measureText(i);return i||(i={width:16},console.warn("-------微信获取文字宽度失败----等待修复---------")),i},I.getUrlEncode=function(i,e){return"arraybuffer"==e?"":"utf8"},I.downLoadFile=function(i,e,n,t){void 0===e&&(e=""),void 0===t&&(t="utf8"),w.getFileInfo(i)?null!=n&&n.runWith([0]):w.downLoadFile(i,e,n,t)},I.remove=function(i,e){w.deleteFile("",i,e,"",0)},I.removeAll=function(){w.deleteAll()},I.hasNativeFile=function(i){return w.isLocalNativeFile(i)},I.getFileInfo=function(i){return w.getFileInfo(i)},I.getFileList=function(){return w.filesListObj},I.exitMiniProgram=function(){I.window.my.exitMiniProgram()},I.onMkdirCallBack=function(i,e){i||(w.filesListObj=JSON.parse(e.data),w.fakeObj=JSON.parse(e.data))},I.pixelRatio=function(){if(!I.EnvConfig.pixelRatioInt)try{return I.EnvConfig.pixelRatioInt=I.systemInfo.pixelRatio,I.systemInfo.pixelRatio}catch(i){}return I.EnvConfig.pixelRatioInt},I.createElement=function(i){var e,n;if("canvas"==i)return 1==I.idx?(n=I.window.canvas.getRealCanvas(),I.window.my.isIDE||(e=n.getContext,n.getContext=function(i){i=e.apply(n,[i]);return i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),i})):n=I._preCreateElement(i),n.style||(n.style={}),I.idx++,n;if("textarea"==i||"input"==i)return I.onCreateInput(i);if("div"!=i)return I._preCreateElement(i);i=I._preCreateElement(i);return i.contains=function(i){return null},i.removeChild=function(i){},i},I.onCreateInput=function(i){i=I._preCreateElement(i);return i.focus=b.wxinputFocus,i.blur=b.wxinputblur,i.value=0,i.placeholder={},i.type={},i.setColor=function(i){},i.setType=function(i){},i.setFontFace=function(i){},i.contains=function(i){return null},i},I.createShaderCondition=function(i){var e=this;return function(){return e[i.replace("this.","")]}},I.EnvConfig=null,I.window=null,I._preCreateElement=null,I._inited=!1,I.systemInfo=null,I.isPosMsgYu=!1,I.autoCacheFile=!1,I.minClearSize=5242880,I.AutoCacheDownFile=!1,I.baseDir="component/",I._measureText=null,I.parseXMLFromString=function(i){var e;i=i.replace(/>\s+</g,"><");try{e=(new n.Parser.DOMParser).parseFromString(i,"text/xml")}catch(i){throw"需要引入xml解析库文件"}return e},I.idx=1,i(I,["nativefiles",function(){return this.nativefiles=["layaNativeDir"]}]),I);function I(){}!function(o){function a(){a.__super.call(this)}t(a,"laya.tbplugin.mini.MiniAccelerator",o,"MiniAccelerator$11");var i=a.prototype;i.on=function(i,e,n,t){return o.prototype.on.call(this,i,e,n,t),a.startListen(this.onDeviceOrientationChange),this},i.off=function(i,e,n,t){return void 0===t&&(t=!1),this.hasListener(i)||a.stopListen(),o.prototype.off.call(this,i,e,n,t)},a.__init__=function(){try{var i=laya.device.motion.Accelerator;if(!i)return;i.prototype.on=a.prototype.on,i.prototype.off=a.prototype.off}catch(i){}},a.startListen=function(i){if(a._callBack=i,!a._isListening){a._isListening=!0;try{x.window.my.onAccelerometerChange(laya.tbplugin.mini.MiniAccelerator.onAccelerometerChange)}catch(i){}}},a.stopListen=function(){a._isListening=!1;try{x.window.my.stopAccelerometer({})}catch(i){}},a.onAccelerometerChange=function(i){var e={};e.acceleration=i,e.accelerationIncludingGravity=i,e.rotationRate={},null!=a._callBack&&a._callBack(e)},a._isListening=!1,a._callBack=null}(l);var M=(t(N,"laya.tbplugin.mini.MiniLoader",l,"MiniLoader$11"),N.prototype.load=function(i,e,n,t,o){void 0===n&&(n=!0),void 0===o&&(o=!1);var a=this;if(0===(a._url=i).indexOf("data:image")?a._type=e="image":a._type=e=e||a.getTypeFromUrl(i),a._cache=n,a._data=null,!o&&p.loadedMap[_.formatURL(i)])return a._data=p.loadedMap[_.formatURL(i)],this.event("progress",1),void this.event("complete",a._data);if(null!=p.parserMap[e])return a._customParse=!0,void(p.parserMap[e]instanceof laya.utils.Handler?p.parserMap[e].runWith(this):p.parserMap[e].call(null,this));var l=x.getUrlEncode(i,e),s=g.getFileExtension(i);if(-1!=N._fileTypeArr.indexOf(s)||"image"==e)x.EnvConfig.load.call(this,i,e,n,t,o);else if(w.getFileInfo(i)){(f=w.getFileInfo(_.formatURL(i))).encoding=null==f.encoding?"utf8":f.encoding;var r=w.getFileNativePath(f.md5);w.readFile(r,f.encoding,new h(N,N.onReadNativeCallBack,[l,i,e,n,t,o,a]),i)}else{if(w.isLocalNativeFile(i)){if(x.subNativeFiles&&0==x.subNativeheads.length)for(var u in x.subNativeFiles){var d=x.subNativeFiles[u];x.subNativeheads=x.subNativeheads.concat(d);for(var c=0;c<d.length;c++)x.subMaps[d[c]]=u+"/"+d[c]}return!x.subNativeFiles||-1==i.indexOf("/")||(s=i.split("/")[0]+"/")&&-1!=x.subNativeheads.indexOf(s)&&(r=x.subMaps[s],i=i.replace(s,r)),void w.readFile(x.baseDir+v.addVersionPrefix(i),l,new h(N,N.onReadNativeCallBack,[l,i,e,n,t,o,a]))}var f;_.formatURL(i);(f=w.getFileInfo(i))?(f.encoding=null==f.encoding?"utf8":f.encoding,w.readFile(f.url,l,new h(N,N.onReadNativeCallBack,[l,i,e,n,t,o,a]),i)):"image"==a.type||"htmlimage"==a.type?x.EnvConfig.load.call(a,i,e,n,t,o):(i=_.formatURL(i),"image"!=e&&(-1==i.indexOf("http://")&&-1==i.indexOf("https://")||w.isLocalNativeFile(i))?w.readFile(x.baseDir+i,l,new h(N,N.onReadNativeCallBack,[l,i,e,n,t,o,a]),i):w.downFiles(encodeURI(i),l,new h(N,N.onReadNativeCallBack,[l,i,e,n,t,o,a]),i,x.AutoCacheDownFile))}},N.onReadNativeCallBack=function(i,e,n,t,o,a,l,s,r){void 0===t&&(t=!0),void 0===a&&(a=!1),(s=void 0===s?0:s)?1==s&&l.onError&&l.onError(r):(r="json"==n||"atlas"==n?x.getJson(r.data):"xml"==n?g.parseXMLFromString(r.data):r.data,l.onLoaded(r))},i(N,["_fileTypeArr",function(){return this._fileTypeArr=["png","jpg","bmp","jpeg","gif"]}]),N);function N(){N.__super.call(this)}var D=function(){function i(){this._sound=null,this.url=null,this.loaded=!1,this.readyUrl=null,i.__super.call(this),this._sound=i._createSound()}t(i,"laya.tbplugin.mini.MiniSound",l,"MiniSound$11");var e=i.prototype;return e.load=function(i){this.event("error","Not support play sound")},e.onDownLoadCallBack=function(i,e,n){var t,o;void 0===n&&(n=""),!e&&this._sound?x.autoCacheFile?(o=""==n?w.isLocalNativeFile(i)?(t=i,""==(e=""!=_.rootPath?_.rootPath:_._basePath)||-1==i.indexOf("http://")&&-1==i.indexOf("https://")||(o=i.split(e)[1]),x.baseDir+(o=o||t)):(t=w.getFileInfo(i))&&t.md5?(t=t.md5,w.getFileNativePath(t)):-1==i.indexOf("http://")&&-1==i.indexOf("https://")&&-1==i.indexOf(x.window.my.env.USER_DATA_PATH)?x.baseDir+i:i:n,this._sound.src=this.url=o):((w.isLocalNativeFile(i)||-1==i.indexOf("http://")&&-1==i.indexOf("https://")&&-1==i.indexOf(x.window.my.env.USER_DATA_PATH))&&(i=x.baseDir+i),this._sound.src=i):this.event("error")},e.play=function(i,e){return void 0===i&&(i=0),void 0===e&&(e=0),null},e.dispose=function(){this._sound&&(this._sound.src="",i._audioCache.push(this._sound),this._sound=null,this.readyUrl=this.url=null)},o(0,e,"duration",function(){return this._sound.duration}),i._createSound=function(){return null},i._id=0,i._audioCache=[],i}();!function(i){function e(i){this._audio=null,this._onEnd=null,this._onCanplay=null,this._onError=null,this._miniSound=null,e.__super.call(this),this._audio=i._sound,this._miniSound=i,this._onEnd=e.bindToThis(this.__onEnd,this),this._onCanplay=e.bindToThis(this.onCanPlay,this),this._onError=e.bindToThis(this.onError,this),this.addEventListener()}t(e,"laya.tbplugin.mini.MiniSoundChannel",i,"MiniSoundChannel$11");var n=e.prototype;n.addEventListener=function(){this._audio.onError(this._onError),this._audio.onCanplay(this._onCanplay)},n.offEventListener=function(){this._audio.offError(this._onError),this._audio.offCanplay(this._onCanplay),this._audio.offEnded(this._onEnd)},n.onError=function(i){console.log("-----1---------------minisound-----url:",this.url),console.log(i),this.event("error"),this._audio&&(this._miniSound.dispose(),this.offEventListener(),this._audio=this._miniSound=null)},n.onCanPlay=function(){this._audio&&(this.event("complete"),this.offEventListener(),this._audio.onEnded(this._onEnd),this.isStopped?this.stop():this.play())},n.__onEnd=function(){if(1==this.loops)return this.completeHandler&&(a.timer.once(10,this,this.__runComplete,[this.completeHandler],!1),this.completeHandler=null),this.stop(),void this.event("complete");0<this.loops&&this.loops--,this.startTime=0,this.play()},n.play=function(){this.isStopped=!1,y.addChannel(this),this._audio&&this._audio.play()},n.stop=function(){i.prototype.stop.call(this),this.isStopped=!0,y.removeChannel(this),this.completeHandler=null,this._audio&&(this._audio.stop(),this.loop||(this.offEventListener(),this._miniSound.dispose(),this._miniSound=null,this._audio=null))},n.pause=function(){this.isStopped=!0,this._audio&&this._audio.pause()},n.resume=function(){this._audio&&(this.isStopped=!1,y.addChannel(this),this._audio.play())},o(0,n,"startTime",function(){return this._audio?this._audio.startTime:0},function(i){this._audio&&(this._audio.startTime=i)}),o(0,n,"autoplay",function(){return!!this._audio&&this._audio.autoplay},function(i){this._audio&&(this._audio.autoplay=i)}),o(0,n,"duration",function(){return this._audio?this._audio.duration:0}),o(0,n,"position",function(){return this._audio?this._audio.currentTime:0}),o(0,n,"loop",function(){return!!this._audio&&this._audio.loop},function(i){this._audio&&(this._audio.loop=i)}),o(0,n,"volume",function(){return this._audio?this._audio.volume:1},function(i){this._audio&&(this._audio.volume=i)}),e.bindToThis=function(i,e){return i.bind(e)}}(m)}(window,(document,Laya)),"function"==typeof define&&define.amd&&define("laya.core",["require","exports"],function(i,e){"use strict";for(var n in Object.defineProperty(e,"__esModule",{value:!0}),Laya){var t=Laya[n];t&&t.__isclass&&(e[n]=t)}}); |