Added old files
This commit is contained in:
parent
9ae92803ce
commit
ef3620f4f9
86 changed files with 2157 additions and 0 deletions
28
sources/scripts/speaker.js
Normal file
28
sources/scripts/speaker.js
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
'use strict'
|
||||
|
||||
function Speaker () {
|
||||
this.effect = new Audio()
|
||||
|
||||
this.audio_catalog = {}
|
||||
|
||||
this.is_muted = false
|
||||
|
||||
this.play_effect = function (name) {
|
||||
this.effect = this.load(name, 'effect', `media/audio/effect/${name}.ogg`)
|
||||
this.effect.play()
|
||||
}
|
||||
|
||||
this.load = function (name, role, src, loop = false) {
|
||||
const audio_id = role + '_' + name
|
||||
if (!(audio_id in this.audio_catalog)) {
|
||||
const audio = new Audio()
|
||||
audio.name = name
|
||||
audio.src = src
|
||||
audio.loop = loop
|
||||
audio.mute = 'muted'
|
||||
this.audio_catalog[audio_id] = audio
|
||||
}
|
||||
this.audio_catalog[audio_id].currentTime = 0
|
||||
return this.audio_catalog[audio_id]
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue