GamePortrait/node_modules/.cache/babel-loader/71ee225da403a5a0d6af8708765ca4dba3c6c0c212eab5180fc27e681b5af89f.json

1 line
2.6 KiB
JSON

{"ast":null,"code":"/* eslint-disable */\nimport $store from \"@/store\";\nconst volume = $store.state.config.volume;\nlet Mp3List = [],\n num = 0;\nfunction getBlob(key) {\n const soundList = $store.state.config.soundList;\n const language = $store.state.config.$Type == \"cn\" || $store.state.config.$Type == \"tw\" ? \"cn\" : \"en\";\n let blob = \"\";\n try {\n blob = soundList[`${language}_${key}`];\n blob = window.webkitURL.createObjectURL(blob) || URL.createObjectURL(blob);\n } catch (err) {\n console.warn(err, key);\n }\n return blob;\n}\nlet audio = null;\nconst audioElement = document.getElementById(\"Audio\");\nconst sourceElement = document.getElementById(\"audioSourceAside\");\naudio = audioElement;\naudio.addEventListener(\"ended\", () => {\n nextAudio(audio, sourceElement);\n});\nfunction audioMp3(mp3List) {\n const effectsVolume = $store.state.config.effectsVolume;\n // const audioElement = document.createElement(\"audio\")\n // const sourceElement = document.createElement(\"source\")\n // audio.appendChild(sourceElement)\n // audio.volume = volume.effects / 100\n audio.muted = !effectsVolume;\n Mp3List = mp3List;\n var mp3 = new Object();\n mp3.mp3List = mp3List;\n mp3.auto_play = false;\n mp3.loop = false;\n mp3.Play = function () {\n if (this.mp3List[0]) {\n sourceElement.src = getBlob(this.mp3List[0]);\n sourceElement.type = \"audio/mpeg\";\n audio.pause();\n audio.load();\n setTimeout(() => {\n audio.play().catch(err => {\n console.log(err);\n }, 200);\n });\n }\n };\n mp3.Pause = function () {\n audio.pause();\n };\n mp3.Muted = function () {\n audio.muted ? audio.muted = false : audio.muted = true;\n };\n mp3.volumeAdd = function () {\n if (audio.volume.toFixed(1) >= 1) {\n audio.volume = 1;\n } else {\n audio.volume = audio.volume + 0.1;\n }\n };\n mp3.volumeMinus = function () {\n if (audio.volume.toFixed(1) <= 0) {\n audio.volume = 0;\n } else {\n audio.volume = audio.volume - 0.1;\n }\n };\n return mp3;\n}\nfunction nextAudio(audio, sourceElement) {\n num += 1;\n // console.log(Mp3List, num)\n if (Mp3List && num < Mp3List.length) {\n sourceElement.src = getBlob(Mp3List[num]);\n sourceElement.type = \"audio/mpeg\";\n audio.load();\n setTimeout(() => {\n audio.play().catch(err => {\n console.log(err);\n }, 500);\n });\n } else {\n audio.pause();\n audio.currentTime = 0.0;\n num = 0;\n audio.removeEventListener(\"ended\", () => {});\n }\n}\nexport { audioMp3 };","map":null,"metadata":{},"sourceType":"module","externalDependencies":[]}