diff options
| author | caleb.mabry.15@cnu.edu <caleb.mabry.15@cnu.edu> | 2022-03-17 20:00:07 -0400 |
|---|---|---|
| committer | caleb.mabry.15@cnu.edu <caleb.mabry.15@cnu.edu> | 2022-03-17 20:00:07 -0400 |
| commit | 1899c8058fde577318c1911a35108ea8d91cd1a7 (patch) | |
| tree | 3a955d4086c4b1ba1b512c199c12bb86d6fed893 /webAO | |
| parent | 34653b82f175af4df5995ce9194fd8ffbaed5015 (diff) | |
Adding blip sounds to actual audio tags
Diffstat (limited to 'webAO')
| -rw-r--r-- | webAO/client.js | 11 | ||||
| -rw-r--r-- | webAO/client/aoHost.js | 5 | ||||
| -rw-r--r-- | webAO/components/__tests__/blips.test.js | 9 | ||||
| -rw-r--r-- | webAO/components/blip.js | 17 |
4 files changed, 33 insertions, 9 deletions
diff --git a/webAO/client.js b/webAO/client.js index 8bac1cc..7e82d91 100644 --- a/webAO/client.js +++ b/webAO/client.js @@ -1674,15 +1674,8 @@ class Viewport { ]; // Allocate multiple blip audio channels to make blips less jittery - - this.blipChannels = new Array( - new Audio(`${AO_HOST}sounds/general/sfx-blipmale.opus`), - new Audio(`${AO_HOST}sounds/general/sfx-blipmale.opus`), - new Audio(`${AO_HOST}sounds/general/sfx-blipmale.opus`), - new Audio(`${AO_HOST}sounds/general/sfx-blipmale.opus`), - new Audio(`${AO_HOST}sounds/general/sfx-blipmale.opus`), - new Audio(`${AO_HOST}sounds/general/sfx-blipmale.opus`), - ); + const blipSelectors = document.getElementsByClassName('blipSound') + this.blipChannels = [...blipSelectors]; this.blipChannels.forEach((channel) => channel.volume = 0.5); this.blipChannels.forEach((channel) => channel.onerror = opusCheck(channel)); this.currentBlipChannel = 0; diff --git a/webAO/client/aoHost.js b/webAO/client/aoHost.js new file mode 100644 index 0000000..b387608 --- /dev/null +++ b/webAO/client/aoHost.js @@ -0,0 +1,5 @@ +import queryParser from '../utils/queryParser' +let { asset } = queryParser(); +const DEFAULT_HOST = 'http://attorneyoffline.de/base/'; +const AO_HOST = asset || DEFAULT_HOST +export default AO_HOST diff --git a/webAO/components/__tests__/blips.test.js b/webAO/components/__tests__/blips.test.js new file mode 100644 index 0000000..9c57e78 --- /dev/null +++ b/webAO/components/__tests__/blips.test.js @@ -0,0 +1,9 @@ +import createBlip from "../blip"; + +describe('createBlip', () => { + test('create 3 blips audios', () => { + document.body.innerHTML = `` + createBlip(3) + expect(document.getElementsByClassName('blipSound').length).toBe(3) + }) +})
\ No newline at end of file diff --git a/webAO/components/blip.js b/webAO/components/blip.js new file mode 100644 index 0000000..409b907 --- /dev/null +++ b/webAO/components/blip.js @@ -0,0 +1,17 @@ +import AO_HOST from '../client/aoHost' + +/** + * + * @param {number} amountOfBlips Amount of Blips to put on page + */ +const createBlip = (amountOfBlips) => { + for (let i = 0; i < amountOfBlips; i++) { + const audio = document.createElement('audio') + const blipUrl = `${AO_HOST}sounds/general/sfx-blipmale.opus` + audio.setAttribute('class', 'blipSound') + audio.setAttribute('src', blipUrl) + document.body.appendChild(audio) + } +} +createBlip(3) +export default createBlip
\ No newline at end of file |
