diff options
| -rw-r--r-- | webAO/client.js | 12 | ||||
| -rw-r--r-- | webAO/components/audioChannels.js | 13 | ||||
| -rw-r--r-- | webpack.config.js | 3 |
3 files changed, 21 insertions, 7 deletions
diff --git a/webAO/client.js b/webAO/client.js index 34a1b4b..739f170 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -1698,12 +1698,8 @@ class Viewport { this.testimonyAudio = document.getElementById('client_testimonyaudio'); this.testimonyAudio.src = `${AO_HOST}sounds/general/sfx-guilty.opus`; - this.music = new Array( - new Audio(`${AO_HOST}sounds/music/trial (aa).opus`), - new Audio(`${AO_HOST}sounds/music/trial (aa).opus`), - new Audio(`${AO_HOST}sounds/music/trial (aa).opus`), - new Audio(`${AO_HOST}sounds/music/trial (aa).opus`), - ); + const audioChannels = document.getElementsByClassName('audioChannel') + this.music = [...audioChannels]; this.music.forEach((channel) => channel.volume = 0.5); this.music.forEach((channel) => channel.onerror = opusCheck(channel)); @@ -2621,6 +2617,10 @@ window.imgError = imgError; * @param {HTMLImageElement} image the element containing the missing sound */ export function opusCheck(channel) { + const audio = channel.src + if (audio === '') { + return + } console.info(`failed to load sound ${channel.src}`); let oldsrc = ''; oldsrc = channel.src; diff --git a/webAO/components/audioChannels.js b/webAO/components/audioChannels.js new file mode 100644 index 0000000..1979653 --- /dev/null +++ b/webAO/components/audioChannels.js @@ -0,0 +1,13 @@ +/** + * + * @param {number} amountOfChannels Amount of Blips to put on page + */ +const createAudioChannels = (amountOfChannels) => { + for (let i = 0; i < amountOfChannels; i++) { + const audioChannel = document.createElement('audio') + audioChannel.setAttribute('class', 'audioChannel') + document.body.appendChild(audioChannel) + } +} +createAudioChannels(4) +export default createAudioChannels diff --git a/webpack.config.js b/webpack.config.js index 5c8b1de..aa52deb 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -17,6 +17,7 @@ module.exports = { client: './webAO/client.js', master: './webAO/master.js', dom: glob.sync('./webAO/dom/*.js'), + components: glob.sync('./webAO/components/*.js') }, node: { global: true, @@ -86,7 +87,7 @@ module.exports = { new HtmlWebpackPlugin({ title: 'Attorney Online', filename: 'client.html', - chunks: ['client', 'ui', 'dom'], + chunks: ['client', 'ui', 'dom', 'components'], template: 'public/client.html', }), new webpack.DefinePlugin({ |
