aboutsummaryrefslogtreecommitdiff
path: root/webAO/components
diff options
context:
space:
mode:
authorcaleb.mabry.15@cnu.edu <caleb.mabry.15@cnu.edu>2022-03-17 20:00:07 -0400
committercaleb.mabry.15@cnu.edu <caleb.mabry.15@cnu.edu>2022-03-17 20:00:07 -0400
commit1899c8058fde577318c1911a35108ea8d91cd1a7 (patch)
tree3a955d4086c4b1ba1b512c199c12bb86d6fed893 /webAO/components
parent34653b82f175af4df5995ce9194fd8ffbaed5015 (diff)
Adding blip sounds to actual audio tags
Diffstat (limited to 'webAO/components')
-rw-r--r--webAO/components/__tests__/blips.test.js9
-rw-r--r--webAO/components/blip.js17
2 files changed, 26 insertions, 0 deletions
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