mirror of
https://github.com/VickScarlet/lifeRestart.git
synced 2025-07-15 08:42:41 +08:00
1 line
28 KiB
JavaScript
1 line
28 KiB
JavaScript
!function(t,o){o.un,o.uns;var e=o.static,n=o.class,a=o.getset,d=(o.__newvec,laya.utils.Browser),l=o.Config,s=(laya.events.Event,laya.events.EventDispatcher),r=laya.resource.HTMLImage,m=laya.utils.Handler,u=laya.display.Input,p=laya.net.Loader,i=(laya.net.LocalStorage,laya.maths.Matrix,laya.renders.Render),c=laya.utils.RunDriver,h=(laya.media.Sound,laya.media.SoundChannel),f=laya.media.SoundManager,v=laya.tt.mini.TTMiniAdapter,g=laya.net.URL,y=laya.utils.Utils,w=(n(_,"laya.hw.mini.HWMiniAdapter"),_.getJson=function(i){return JSON.parse(i)},_.init=function(i,e){if(void 0===i&&(i=!1),void 0===e&&(e=!1),!_._inited&&(_._inited=!0,(_.window=t).hasOwnProperty("hbs"))){_.isZiYu=e,_.isPosMsgYu=i,_.EnvConfig={};try{laya.webgl.resource.WebGLCanvas.premulAlpha=!0}catch(i){}if(_.isZiYu||(F.setNativeFileDir("/layaairGame"),F.existDir(F.fileNativeDir,m.create(_,_.onMkdirCallBack))),"ios 10.1.1"===(_.systemInfo=_.window.hbs.getSystemInfoSync()).system.toLowerCase())try{laya.webgl.resource.WebGLCharImage.canUseCanvas=!1}catch(i){}_.window.focus=function(){},o._getUrlPath=function(){},o.getUrlPath=function(){},_.window.logtime=function(i){},_.window.alertTimeLog=function(i){},_.window.resetShareInfo=function(){},_._preCreateElement=d.createElement,d.createElement=_.createElement,c.createShaderCondition=_.createShaderCondition,y.parseXMLFromString=_.parseXMLFromString,u._createInputElement=L._createInputElement,_.EnvConfig.load=p.prototype.load,p.prototype.load=P.prototype.load,p.prototype._loadImage=C.prototype._loadImage,l.useRetinalCanvas=!0}},_.measureText=function(i){i=_._measureText(i);return i||(i={width:16},console.warn("-------微信获取文字宽度失败----等待修复---------")),i},_.getUrlEncode=function(i,e){return"arraybuffer"==e?"binary":"utf8"},_.downLoadFile=function(i,e,t,n){void 0===e&&(e=""),void 0===n&&(n="utf8"),F.getFileInfo(i)?null!=t&&t.runWith([0]):F.downLoadFile(i,e,t,n)},_.remove=function(i,e){F.deleteFile("",i,e,"",0)},_.removeAll=function(){F.deleteAll()},_.hasNativeFile=function(i){return F.isLocalNativeFile(i)},_.getFileInfo=function(i){return F.getFileInfo(i)},_.getFileList=function(){return F.filesListObj},_.exitMiniProgram=function(){_.window.hbs.exitMiniProgram()},_.onMkdirCallBack=function(i,e){i||(F.filesListObj=JSON.parse(e.data),F.fakeObj=JSON.parse(e.data)||{})},_.pixelRatio=function(){if(!_.EnvConfig.pixelRatioInt)try{return _.EnvConfig.pixelRatioInt=_.systemInfo.pixelRatio,_.systemInfo.pixelRatio}catch(i){}return _.EnvConfig.pixelRatioInt},_.createElement=function(i){if("textarea"==i||"input"==i)return _.onCreateInput(i);if("div"!=i)return _._preCreateElement(i);i=_._preCreateElement(i);return i.contains=function(i){return null},i.removeChild=function(i){},i},_.onCreateInput=function(i){i=_._preCreateElement(i);return i.focus=L.inputFocus,i.blur=L.inputblur,i.style={},i.value=0,i.parentElement={},i.placeholder={},i.type={},i.setColor=function(i){},i.setType=function(i){},i.setFontFace=function(i){},i.addEventListener=function(i){},i.contains=function(i){return null},i.removeChild=function(i){},i},_.createShaderCondition=function(i){var e=this;return function(){return e[i.replace("this.","")]}},_.sendAtlasToOpenDataContext=function(i){if(!laya.hw.mini.HWMiniAdapter.isZiYu){var e=p.getRes(g.formatURL(i));if(!e)throw"传递的url没有获取到对应的图集数据信息,请确保图集已经过!";e.meta.image.split(",");if(e.meta&&e.meta.image)for(var t=e.meta.image.split(","),n=0<=i.indexOf("/")?"/":"\\",n=i.lastIndexOf(n),o=0<=n?i.substr(0,n+1):"",a=0,l=t.length;a<l;a++)t[a]=o+t[a];else t=[i.replace(".json",".png")];for(a=0;a<t.length;a++){var s=t[a];_.postInfoToContext(i,s,e)}}},_.postInfoToContext=function(i,e,t){var n={frames:t.frames,meta:t.meta},t=e,e=F.getFileInfo(g.formatURL(e)),o=e?(o=e.md5,F.getFileNativePath(o)):t;if(!o)throw"获取图集的磁盘url路径不存在!";_.window.hbs.postMessage({url:i,atlasdata:n,imgNativeUrl:o,imgReadyUrl:t,isLoad:"opendatacontext"})},_.sendSinglePicToOpenDataContext=function(i){var e,t=g.formatURL(i),n=F.getFileInfo(t);if(n?(e=n.md5,e=F.getFileNativePath(e),i=t):e=i,!e)throw"获取图集的磁盘url路径不存在!";_.window.hbs.postMessage({url:i,imgNativeUrl:e,imgReadyUrl:i,isLoad:"openJsondatacontextPic"})},_.sendJsonDataToDataContext=function(i){if(!laya.hw.mini.HWMiniAdapter.isZiYu){var e=p.getRes(i);if(!e)throw"传递的url没有获取到对应的图集数据信息,请确保图集已经过!";_.window.hbs.postMessage({url:i,atlasdata:e,isLoad:"openJsondatacontext"})}},_.EnvConfig=null,_.window=null,_._preCreateElement=null,_._inited=!1,_.systemInfo=null,_.isZiYu=!1,_.isPosMsgYu=!1,_.autoCacheFile=!0,_.minClearSize=5242880,_.subNativeFiles=null,_.subNativeheads=[],_.subMaps=[],_.AutoCacheDownFile=!1,_._measureText=null,_.parseXMLFromString=function(i){var e;i=i.replace(/>\s+</g,"><");try{e=(new t.DOMParser).parseFromString(i,"text/xml")}catch(i){throw"需要引入xml解析库文件"}return e},_.idx=1,e(_,["nativefiles",function(){return this.nativefiles=["layaNativeDir","wxlocal"]}]),_);function _(){}var F=(n(b,"laya.hw.mini.MiniFileMgr",null,"MiniFileMgr$9"),b.isLocalNativeFile=function(i){for(var e=0,t=w.nativefiles.length;e<t;e++)if(-1!=i.indexOf(w.nativefiles[e]))return!0;return!1},b.getFileInfo=function(i){i=b.fakeObj[i];return null==i?null:i},b.read=function(i,e,t,n,o,a){void 0===e&&(e="utf8"),void 0===o&&(o=!1),void 0===a&&(a=""),i=""==(n=void 0===n?"":n)||-1==n.indexOf("http://")&&-1==n.indexOf("https://")?i:b.getFileNativePath(i),b.fs.readFile({filePath:i,encoding:e,success:function(i){null!=t&&t.runWith([0,i])},fail:function(i){i&&""!=n?b.downFiles(n,e,t,n,o,a):null!=t&&t.runWith([1])}})},b.downFiles=function(e,t,n,o,a,l,s){void 0===t&&(t="ascii"),void 0===o&&(o=""),void 0===a&&(a=!1),void 0===l&&(l=""),void 0===s&&(s=!0),b.wxdown({url:e,success:function(i){200===i.statusCode?b.readFile(i.tempFilePath,t,n,o,a,l,s):403===i.statusCode?null!=n&&n.runWith([0,e]):null!=n&&n.runWith([1,i])},fail:function(i){null!=n&&n.runWith([1,i])}}).onProgressUpdate(function(i){null!=n&&n.runWith([2,i.progress])})},b.readFile=function(e,t,n,o,a,i,l){void 0===o&&(o=""),void 0===a&&(a=!1),void 0===i&&(i=""),void 0===l&&(l=!0),b.fs.readFile({filePath:e,encoding:t=void 0===t?"utf8":t,success:function(i){(-1!=e.indexOf("http://")||-1!=e.indexOf("https://"))&&(w.autoCacheFile||a)?(null!=n&&n.runWith([0,i]),b.copyFile(e,o,null,t,l)):null!=n&&n.runWith([0,i])},fail:function(i){i?null!=n&&n.runWith([1,i]):b.filesListObj[o]&&(b.filesListObj[o]==b.fakeObj[o]&&delete b.fakeObj[o],delete b.filesListObj[o])}})},b.downOtherFiles=function(i,e,t,n,o){void 0===t&&(t=""),void 0===n&&(n=!1),void 0===o&&(o=!0),b.wxdown({url:i,success:function(i){200===i.statusCode?(w.autoCacheFile||n)&&-1==t.indexOf("wx.qlogo.cn")&&-1==t.indexOf(".php")?(null!=e&&e.runWith([0,i.tempFilePath]),b.copyFile(i.tempFilePath,t,null,"",o)):null!=e&&e.runWith([0,i.tempFilePath]):null!=e&&e.runWith([1,i])},fail:function(i){null!=e&&e.runWith([1,i])}})},b.downLoadFile=function(i,e,t,n){void 0===e&&(e=""),void 0===n&&(n="ascii"),w.window.navigator.userAgent.indexOf("MiniGame")<0?o.loader.load(i,t):"image"==e||"sound"==e?b.downOtherFiles(i,t,i,!0,!1):b.downFiles(i,n,t,i,!0,e,!1)},b.copyFile=function(t,n,o,a,l){void 0===a&&(a=""),void 0===l&&(l=!0);var i=t.split("/"),s=i[i.length-1],i=b.getFileInfo(n),r=b.getFileNativePath(s);b.fakeObj[n]={md5:s,readyUrl:n,size:0,times:d.now(),encoding:a};var u=b.getCacheUseSize();i?i.readyUrl!=n?b.fs.getFileInfo({filePath:t,success:function(i){l&&52428800<=u+4194304+i.size&&(i.size>w.minClearSize&&(w.minClearSize=i.size),b.onClearCacheRes()),b.deleteFile(t,n,o,a,i.size)},fail:function(i){null!=o&&o.runWith([1,i])}}):null!=o&&o.runWith([0]):b.fs.getFileInfo({filePath:t,success:function(e){l&&52428800<=u+4194304+e.size&&(e.size>w.minClearSize&&(w.minClearSize=e.size),b.onClearCacheRes()),b.fs.copyFile({srcPath:t,destPath:r,success:function(i){b.onSaveFile(n,s,!0,a,o,e.size)},fail:function(i){null!=o&&o.runWith([1,i])}})},fail:function(i){null!=o&&o.runWith([1,i])}})},b.onClearCacheRes=function(){var i,e=w.minClearSize,t=[];for(i in b.filesListObj)"fileUsedSize"!=i&&t.push(b.filesListObj[i]);b.sortOn(t,"times",16);for(var n=0,o=1,a=t.length;o<a;o++){var l=t[o];if(e<=n)break;n+=l.size,b.deleteFile("",l.readyUrl)}},b.sortOn=function(i,t,e){return 16==(e=void 0===e?0:e)?i.sort(function(i,e){return i[t]-e[t]}):18==e?i.sort(function(i,e){return e[t]-i[t]}):i.sort(function(i,e){return i[t]-e[t]})},b.getFileNativePath=function(i){return laya.hw.mini.MiniFileMgr.fileNativeDir+"/"+i},b.deleteFile=function(n,o,a,l,s){void 0===l&&(l=""),void 0===s&&(s=0);var i=b.getFileInfo(o=void 0===o?"":o),i=b.getFileNativePath(i.md5);b.fs.unlink({filePath:i,success:function(i){var e,t=""!=n;""!=n?(e=b.getFileNativePath(n),b.fs.copyFile({srcPath:n,destPath:e,success:function(i){b.onSaveFile(o,n,t,l,a,i.size)},fail:function(i){null!=a&&a.runWith([1,i])}})):b.onSaveFile(o,n,t,l,a,s)},fail:function(i){}})},b.deleteAll=function(){var i,e=[];for(i in b.filesListObj)e.push(b.filesListObj[i]);for(var t=1,n=e.length;t<n;t++){var o=e[t];b.deleteFile("",o.readyUrl)}laya.hw.mini.MiniFileMgr.filesListObj&&laya.hw.mini.MiniFileMgr.filesListObj.fileUsedSize&&(laya.hw.mini.MiniFileMgr.filesListObj.fileUsedSize=0),laya.hw.mini.MiniFileMgr.writeFilesList("",JSON.stringify({}),!1)},b.onSaveFile=function(i,e,t,n,o,a){void 0===t&&(t=!0),void 0===n&&(n=""),void 0===a&&(a=0);var l=i;null==b.filesListObj.fileUsedSize&&(b.filesListObj.fileUsedSize=0),t?(b.getFileNativePath(e),b.filesListObj[l]={md5:e,readyUrl:i,size:a,times:d.now(),encoding:n},b.filesListObj.fileUsedSize=parseInt(b.filesListObj.fileUsedSize)+a,b.writeFilesList(l,JSON.stringify(b.filesListObj),!0),null!=o&&o.runWith([0])):b.filesListObj[l]&&(a=parseInt(b.filesListObj[l].size),b.filesListObj.fileUsedSize=parseInt(b.filesListObj.fileUsedSize)-a,b.fakeObj[l].md5==b.filesListObj[l].md5&&delete b.fakeObj[l],delete b.filesListObj[l],b.writeFilesList(l,JSON.stringify(b.filesListObj),!1),null!=o&&o.runWith([0]))},b.writeFilesList=function(i,e,t){b.fs.writeFile({filePath:b.fileNativeDir+"/"+b.fileListName,encoding:"utf8",data:e,success:function(i){},fail:function(i){}}),!w.isZiYu&&w.isPosMsgYu&&w.window.hbs.postMessage&&w.window.hbs.postMessage({url:i,data:b.filesListObj[i],isLoad:"filenative",isAdd:t})},b.getCacheUseSize=function(){return b.filesListObj&&b.filesListObj.fileUsedSize?b.filesListObj.fileUsedSize:0},b.existDir=function(i,e){b.fs.mkdir({dirPath:i,success:function(i){null!=e&&e.runWith([0,{data:JSON.stringify({})}])},fail:function(i){-1!=i.errMsg.indexOf("file already exists")?b.readSync(b.fileListName,"utf8",e):null!=e&&e.runWith([1,i])}})},b.readSync=function(i,e,t,n){void 0===e&&(e="utf8"),void 0===n&&(n="");var o,i=b.getFileNativePath(i);try{o=b.fs.readFileSync(i,e),null!=t&&t.runWith([0,{data:o}])}catch(i){null!=t&&t.runWith([1])}},b.setNativeFileDir=function(i){b.fileNativeDir=w.window.hbs.env.USER_DATA_PATH+i},b.filesListObj={},b.fakeObj={},b.fileNativeDir=null,b.fileListName="layaairfiles.txt",b.ziyuFileData={},b.ziyuFileTextureData={},b.loadPath="",b.DESCENDING=2,b.NUMERIC=16,e(b,["fs",function(){return this.fs=w.window.hbs.getFileSystemManager()},"wxdown",function(){return this.wxdown=w.window.hbs.downloadFile}]),b);function b(){}var C=(n(E,"laya.hw.mini.MiniImage",null,"MiniImage$9"),E.prototype._loadImage=function(i){var e=this;if(w.isZiYu)E.onCreateImage(i,e,!0);else{var t,n,o=!1;if(F.isLocalNativeFile(i)){if(-1==i.indexOf("http://")&&-1==i.indexOf("https://")||(i=""!=F.loadPath?i.split(F.loadPath)[1]:(n=i,(i=""!=(t=""!=g.rootPath?g.rootPath:g.basePath)?i.split(t)[1]:i)||n)),w.subNativeFiles&&0==w.subNativeheads.length)for(var a in w.subNativeFiles){var l=w.subNativeFiles[a];w.subNativeheads=w.subNativeheads.concat(l);for(var s=0;s<l.length;s++)w.subMaps[l[s]]=a+"/"+l[s]}!w.subNativeFiles||-1==i.indexOf("/")||(t=i.split("/")[0]+"/")&&-1!=w.subNativeheads.indexOf(t)&&(n=w.subMaps[t],i=i.replace(t,n))}else o=!0,i=g.formatURL(i);F.getFileInfo(i)?E.onCreateImage(i,e,!o):-1==i.indexOf("http://")&&-1==i.indexOf("https://")||w.isZiYu?E.onCreateImage(i,e,!0):F.downOtherFiles(encodeURI(i),new m(E,E.onDownImgCallBack,[i,e]),i)}},E.onDownImgCallBack=function(i,e,t,n){void 0===n&&(n=""),t?e.onError(null):E.onCreateImage(i,e,!1,n)},E.onCreateImage=function(e,t,i,n){var o,a,l;function s(){l.onload=null,l.onerror=null,delete t.imgCache[e]}void 0===i&&(i=!1),void 0===n&&(n=""),a=w.autoCacheFile?i?w.isZiYu?(o=g.formatURL(e),F.ziyuFileTextureData[o]||e):e:""!=n?n:(a=F.getFileInfo(e).md5,F.getFileNativePath(a)):i?e:n,null==t.imgCache&&(t.imgCache={});i=function(){s(),t.onLoaded(l)},n=function(){s(),delete F.filesListObj[e],delete F.fakeObj[e],t.event("error","Load image failed")};"nativeimage"==t._type?((l=new d.window.Image).crossOrigin="",l.onload=i,l.onerror=n,l.src=a,t.imgCache[e]=l):new r.create(a,{onload:i,onerror:n,onCreate:function(i){l=i,t.imgCache[e]=i}})},E);function E(){}var L=(n(O,"laya.hw.mini.MiniInput",null,"MiniInput$9"),O._createInputElement=function(){u._initInput(u.area=d.createElement("textarea")),u._initInput(u.input=d.createElement("input")),u.inputContainer=d.createElement("div"),u.inputContainer.style.position="absolute",u.inputContainer.style.zIndex=1e5,d.container.appendChild(u.inputContainer),u.inputContainer.setPos=function(i,e){u.inputContainer.style.left=i+"px",u.inputContainer.style.top=e+"px"},o.stage.on("resize",null,O._onStageResize),w.window.hbs.onWindowResize&&w.window.hbs.onWindowResize(function(i){w.window.dispatchEvent&&w.window.dispatchEvent("resize")}),f._soundClass=I,f._musicClass=I;var i=w.systemInfo.model,e=w.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)},O._onStageResize=function(){o.stage._canvasTransform.identity().scale(d.width/i.canvas.width/c.getPixelRatio(),d.height/i.canvas.height/c.getPixelRatio())},O.inputFocus=function(i){var e=u.inputElement.target;e&&!e.editable||(w.window.hbs.offKeyboardConfirm(),w.window.hbs.offKeyboardInput(),w.window.hbs.showKeyboard({defaultValue:e.text,maxLength:e.maxChars,multiple:e.multiline,confirmHold:!0,confirmType:"done",success:function(i){},fail:function(i){}}),w.window.hbs.onKeyboardConfirm(function(i){i=i?i.value:"";e.text=i,e.event("input"),laya.hw.mini.MiniInput.inputEnter()}),w.window.hbs.onKeyboardInput(function(i){i=i?i.value:"";e.multiline||-1==i.indexOf("\n")?(e.text=i,e.event("input")):laya.hw.mini.MiniInput.inputEnter()}))},O.inputEnter=function(){u.inputElement.target.focus=!1},O.inputblur=function(){O.hideKeyboard()},O.hideKeyboard=function(){w.window.hbs.offKeyboardConfirm(),w.window.hbs.offKeyboardInput(),w.window.hbs.hideKeyboard({success:function(i){console.log("隐藏键盘")},fail:function(i){console.log("隐藏键盘出错:"+(i?i.errMsg:""))}})},O);function O(){}n(x,"laya.hw.mini.MiniLocation",null,"MiniLocation$9"),x.__init__=function(){w.window.navigator.geolocation.getCurrentPosition=x.getCurrentPosition,w.window.navigator.geolocation.watchPosition=x.watchPosition,w.window.navigator.geolocation.clearWatch=x.clearWatch},x.getCurrentPosition=function(e,i,t){var n;(n={success:function(i){null!=e&&e(i)}}).fail=i,w.window.hbs.getLocation(n)},x.watchPosition=function(i,e,t){var n;return x._curID++,(n={}).success=i,n.error=e,x._watchDic[x._curID]=n,o.timer.loop(1e3,null,x._myLoop),x._curID},x.clearWatch=function(i){delete x._watchDic[i],x._hasWatch()||o.timer.clear(null,x._myLoop)},x._hasWatch=function(){for(var i in x._watchDic)if(x._watchDic[i])return!0;return!1},x._myLoop=function(){x.getCurrentPosition(x._mySuccess,x._myError)},x._mySuccess=function(i){var e,t={};for(e in t.coords=i,t.timestamp=d.now(),x._watchDic)x._watchDic[e].success&&x._watchDic[e].success(t)},x._myError=function(i){for(var e in x._watchDic)x._watchDic[e].error&&x._watchDic[e].error(i)},x._watchDic={},x._curID=0;function x(){}(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=v.window.tt.createVideo({width:i=void 0===i?320:i,height:e=void 0===e?240:e,autoplay:!0})}n(i,"laya.tt.mini.MiniVideo",null,"MiniVideo$7");var e=i.prototype;e.on=function(i,e,t){"loadedmetadata"==i?(this.onPlayFunc=t.bind(e),this.videoElement.onPlay=this.onPlayFunction.bind(this)):"ended"==i&&(this.onEndedFunC=t.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,t){"loadedmetadata"==i?(this.onPlayFunc=t.bind(e),this.videoElement.offPlay=this.onPlayFunction.bind(this)):"ended"==i&&(this.onEndedFunC=t.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)},a(0,e,"duration",function(){return this._duration}),a(0,e,"paused",function(){return!!this.videoElement&&this.videoElement.paused}),a(0,e,"loop",function(){return!!this.videoElement&&this.videoElement.loop},function(i){this.videoElement&&(this.videoElement.loop=i)}),a(0,e,"currentTime",function(){return this.videoElement?this.videoElement.initialTime:0},function(i){this.videoElement&&(this.videoElement.initialTime=i)}),a(0,e,"ended",function(){return this.videoend}),a(0,e,"muted",function(){return!!this.videoElement&&this.videoElement.muted},function(i){this.videoElement&&(this.videoElement.muted=i)}),a(0,e,"videoWidth",function(){return this.videoElement?this.videoElement.width:0}),a(0,e,"videoHeight",function(){return this.videoElement?this.videoElement.height:0}),a(0,e,"playbackRate",function(){return this.videoElement?this.videoElement.playbackRate:0},function(i){this.videoElement&&(this.videoElement.playbackRate=i)}),a(0,e,"x",function(){return this.videoElement?this.videoElement.x:0},function(i){this.videoElement&&(this.videoElement.x=i)}),a(0,e,"y",function(){return this.videoElement?this.videoElement.y:0},function(i){this.videoElement&&(this.videoElement.y=i)}),a(0,e,"currentSrc",function(){return this.videoElement.src}),i.__init__=function(){laya.device.media.Video=i}})(),function(o){function a(){a.__super.call(this)}n(a,"laya.hw.mini.MiniAccelerator",o,"MiniAccelerator$9");var i=a.prototype;i.on=function(i,e,t,n){return o.prototype.on.call(this,i,e,t,n),a.startListen(this.onDeviceOrientationChange),this},i.off=function(i,e,t,n){return void 0===n&&(n=!1),this.hasListener(i)||a.stopListen(),o.prototype.off.call(this,i,e,t,n)},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{w.window.hbs.onAccelerometerChange(laya.hw.mini.MiniAccelerator.onAccelerometerChange)}catch(i){}}},a.stopListen=function(){a._isListening=!1;try{w.window.hbs.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}(s);var P=function(){function v(){v.__super.call(this)}n(v,"laya.hw.mini.MiniLoader",s,"MiniLoader$9");var i=v.prototype;return i.load=function(i,e,t,n,o){void 0===t&&(t=!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=t,a._data=null,!o&&p.loadedMap[g.formatURL(i)])return a._data=p.loadedMap[g.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=w.getUrlEncode(i,e),s=y.getFileExtension(i);if(-1!=v._fileTypeArr.indexOf(s)||"image"==e)w.EnvConfig.load.call(this,i,e,t,n,o);else if(w.isZiYu&&!F.ziyuFileData[i]&&(i=g.formatURL(i)),w.isZiYu&&F.ziyuFileData[i]){s=F.ziyuFileData[i];a.onLoaded(s)}else if(F.getFileInfo(g.formatURL(i))){var r=F.getFileInfo(g.formatURL(i));r.encoding=null==r.encoding?"utf8":r.encoding;var u=F.getFileNativePath(r.md5);F.readFile(u,r.encoding,new m(v,v.onReadNativeCallBack,[l,i,e,t,n,o,a]),g.formatURL(i))}else{if(F.isLocalNativeFile(i)){if(w.subNativeFiles&&0==w.subNativeheads.length)for(var d in w.subNativeFiles){var c=w.subNativeFiles[d];w.subNativeheads=w.subNativeheads.concat(c);for(var h=0;h<c.length;h++)w.subMaps[c[h]]=d+"/"+c[h]}return!w.subNativeFiles||-1==i.indexOf("/")||(u=i.split("/")[0]+"/")&&-1!=w.subNativeheads.indexOf(u)&&(f=w.subMaps[u],i=i.replace(u,f)),void("sound"==e?a._loadSound(i):F.read(i,l,new m(v,v.onReadNativeCallBack,[l,i,e,t,n,o,a])))}var f=i;-1!=g.formatURL(i).indexOf(w.window.hbs.env.USER_DATA_PATH)||-1==i.indexOf("http://")&&-1==i.indexOf("https://")||w.AutoCacheDownFile?(r=F.getFileInfo(i))?(r.encoding=null==r.encoding?"utf8":r.encoding,F.readFile(r.url,l,new m(v,v.onReadNativeCallBack,[l,i,e,t,n,o,a]),i)):"image"==a.type||"htmlimage"==a.type?w.EnvConfig.load.call(a,i,e,t,n,o):(i=g.formatURL(i),"image"!=e&&(-1==i.indexOf("http://")&&-1==i.indexOf("https://")||F.isLocalNativeFile(i))?F.readFile(i,l,new m(v,v.onReadNativeCallBack,[l,i,e,t,n,o,a]),i):F.downFiles(encodeURI(i),l,new m(v,v.onReadNativeCallBack,[l,i,e,t,n,o,a]),i,!0)):"sound"==e?a._loadSound(i):w.EnvConfig.load.call(a,f,e,t,n,o)}},i._loadSound=function(i){var e,t,n;F.isLocalNativeFile(i)?(t=i,n=(n=""==(e=""!=g.rootPath?g.rootPath:g.basePath)||-1==i.indexOf("http://")&&-1==i.indexOf("https://")?n:i.split(e)[1])||t,laya.hw.mini.MiniLoader.onDownLoadCallBack(i,this,0)):(n=g.formatURL(i),!F.isLocalNativeFile(i)&&-1==n.indexOf("http://")&&-1==n.indexOf("https://")||-1!=n.indexOf(w.window.hbs.env.USER_DATA_PATH)?laya.hw.mini.MiniLoader.onDownLoadCallBack(i,this,0):F.downOtherFiles(encodeURI(n),m.create(v,laya.hw.mini.MiniLoader.onDownLoadCallBack,[n,this]),n))},v.onDownLoadCallBack=function(i,e,t,n){var o,a;t?e.event("error","Load sound failed"):(i=a=w.autoCacheFile?n||(F.isLocalNativeFile(i)?(o=i,(a=""==(n=""!=g.rootPath?g.rootPath:g.basePath)||-1==i.indexOf("http://")&&-1==i.indexOf("https://")?a:i.split(n)[1])||o):(o=F.getFileInfo(i))&&o.md5?(o=o.md5,F.getFileNativePath(o)):i):a,(a=new f._soundClass).load(encodeURI(i)),e.onLoaded(a))},v.onReadNativeCallBack=function(i,e,t,n,o,a,l,s,r){void 0===n&&(n=!0),void 0===a&&(a=!1),(s=void 0===s?0:s)?1==s&&(console.log("-----------本地加载失败,尝试外网加载----url:"+e),w.EnvConfig.load.call(l,e,t,n,o,a)):(r="json"==t||"atlas"==t?w.getJson(r.data):"xml"==t?y.parseXMLFromString(r.data):r.data,!w.isZiYu&&w.isPosMsgYu&&"arraybuffer"!=t&&w.window.hbs&&w.window.hbs.postMessage({url:e,data:r,isLoad:"filedata"}),l.onLoaded(r))},e(v,["_fileTypeArr",function(){return this._fileTypeArr=["png","jpg","bmp","jpeg","gif"]}]),v}(),I=function(){function l(){this._sound=null,this.url=null,this.loaded=!1,this.readyUrl=null,l.__super.call(this)}n(l,"laya.hw.mini.MiniSound",s,"MiniSound$9");var i=l.prototype;return i.load=function(i){if(F.isLocalNativeFile(i)?-1==i.indexOf("http://")&&-1==i.indexOf("https://")||(""!=F.loadPath?i=i.split(F.loadPath)[1]:""!=(e=""!=g.rootPath?g.rootPath:g.basePath)&&(i=i.split(e)[1])):i=g.formatURL(i),this.url=i,this.readyUrl=i,l._audioCache[this.readyUrl])this.event("complete");else if(w.autoCacheFile&&F.getFileInfo(i))this.onDownLoadCallBack(i,0);else if(w.autoCacheFile)if(F.isLocalNativeFile(i)){var e,t=i;if(i=(i=""!=(e=""!=g.rootPath?g.rootPath:g.basePath)?i.split(e)[1]:i)||t,w.subNativeFiles&&0==w.subNativeheads.length)for(var n in w.subNativeFiles){var o=w.subNativeFiles[n];w.subNativeheads=w.subNativeheads.concat(o);for(var a=0;a<o.length;a++)w.subMaps[o[a]]=n+"/"+o[a]}!w.subNativeFiles||-1==i.indexOf("/")||(e=i.split("/")[0]+"/")&&-1!=w.subNativeheads.indexOf(e)&&(t=w.subMaps[e],i=i.replace(e,t)),this.onDownLoadCallBack(i,0)}else F.downOtherFiles(encodeURI(i),m.create(this,this.onDownLoadCallBack,[i]),i);else this.onDownLoadCallBack(i,0)},i.onDownLoadCallBack=function(i,e){var t,n;e?this.event("error"):(w.autoCacheFile?(t=F.isLocalNativeFile(i)?(n=i,(t=""==(e=""!=g.rootPath?g.rootPath:g.basePath)||-1==i.indexOf("http://")&&-1==i.indexOf("https://")?t:i.split(e)[1])||n):(n=F.getFileInfo(i))&&n.md5?(n=n.md5,F.getFileNativePath(n)):encodeURI(i),this._sound=l._createSound(),this._sound.src=this.url=t):(this._sound=l._createSound(),this._sound.src=encodeURI(i)),this._sound.onCanplay(l.bindToThis(this.onCanPlay,this)),this._sound.onError(l.bindToThis(this.onError,this)))},i.onError=function(i){this.event("error"),this._sound.offError(null)},i.onCanPlay=function(){this.loaded=!0,this.event("complete"),this._sound.offCanplay(null)},i.play=function(i,e){var t;void 0===i&&(i=0),void 0===e&&(e=0),n=this.url==f._tMusic?(l._musicAudio||(l._musicAudio=l._createSound()),l._musicAudio):l._audioCache[this.readyUrl]?l._audioCache[this.readyUrl]._sound:l._createSound(),w.autoCacheFile&&F.getFileInfo(this.url)?(t=F.getFileInfo(this.url).md5,n.src=this.url=F.getFileNativePath(t)):n.src=encodeURI(this.url);var n=new N(n,this);return n.url=this.url,n.loops=e,n.loop=0===e,n.startTime=i,n.play(),f.addChannel(n),n},i.dispose=function(){var i=l._audioCache[this.readyUrl];i&&(i.src="",i._sound&&(i._sound.destroy(),i._sound=null,i=null),delete l._audioCache[this.readyUrl]),this._sound&&(this._sound.destroy(),this._sound=null),this.url=this.readyUrl=null},a(0,i,"duration",function(){return this._sound.duration}),l._createSound=function(){return l._id++,w.window.hbs.createInnerAudioContext()},l.bindToThis=function(i,e){return i.bind(e)},l._musicAudio=null,l._id=0,l._audioCache={},l}(),N=function(){function t(i,e){this._audio=null,this._onEnd=null,this._miniSound=null,t.__super.call(this),this._audio=i,this._miniSound=e,this._onEnd=t.bindToThis(this.__onEnd,this),i.onEnded(this._onEnd)}n(t,"laya.hw.mini.MiniSoundChannel",h,"MiniSoundChannel$9");var i=t.prototype;return i.__onEnd=function(){if(1==this.loops)return this.completeHandler&&(o.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()},i.play=function(){this.isStopped=!1,f.addChannel(this),this._audio.play()},i.stop=function(){this.isStopped=!0,f.removeChannel(this),this.completeHandler=null,this._audio&&(this._audio.stop(),this._audio.offEnded(null),this._audio.destroy(),this._audio=null,this._miniSound=null,this._onEnd=null)},i.pause=function(){this.isStopped=!0,this._audio.pause()},i.resume=function(){this._audio&&(this.isStopped=!1,f.addChannel(this),this._audio.play())},a(0,i,"startTime",null,function(i){this._audio&&(this._audio.startTime=i)}),a(0,i,"autoplay",function(){return this._audio.autoplay},function(i){this._audio.autoplay=i}),a(0,i,"position",function(){return this._audio?this._audio.currentTime:0}),a(0,i,"duration",function(){return this._audio?this._audio.duration:0}),a(0,i,"loop",function(){return this._audio.loop},function(i){this._audio.loop=i}),a(0,i,"volume",function(){return this._audio?this._audio.volume:1},function(i){this._audio&&(this._audio.volume=i)}),t.bindToThis=function(i,e){return i.bind(e)},t}()}(window,(document,Laya)),"function"==typeof define&&define.amd&&define("laya.core",["require","exports"],function(i,e){"use strict";for(var t in Object.defineProperty(e,"__esModule",{value:!0}),Laya){var n=Laya[t];n&&n.__isclass&&(e[t]=n)}}); |