diff --git a/shared/js/events.ts b/shared/js/events.ts index 26a773b0..8ffe4f40 100644 --- a/shared/js/events.ts +++ b/shared/js/events.ts @@ -40,7 +40,7 @@ namespace events { off(handler_or_events, handler?) { if(typeof handler_or_events === "function") { for(const key of Object.keys(this.handler)) - this.handler[key].remove(handler); + this.handler[key].remove(handler_or_events); } else { if(!Array.isArray(handler_or_events)) handler_or_events = [handler_or_events]; diff --git a/shared/js/main.ts b/shared/js/main.ts index 0a9a0d37..fb5db2dc 100644 --- a/shared/js/main.ts +++ b/shared/js/main.ts @@ -147,15 +147,20 @@ async function initialize_app() { if(!audio.player.initialize()) console.warn(tr("Failed to initialize audio controller!")); - if(audio.player.set_master_volume) - audio.player.set_master_volume(settings.global(Settings.KEY_SOUND_MASTER) / 100); - else - log.warn(LogCategory.GENERAL, tr("Client does not support audio.player.set_master_volume()... May client is too old?")); - if(audio.recorder.device_refresh_available()) - await audio.recorder.refresh_devices(); + + audio.player.on_ready(() => { + if(audio.player.set_master_volume) + audio.player.on_ready(() => audio.player.set_master_volume(settings.global(Settings.KEY_SOUND_MASTER) / 100)); + else + log.warn(LogCategory.GENERAL, tr("Client does not support audio.player.set_master_volume()... May client is too old?")); + if(audio.recorder.device_refresh_available()) + audio.recorder.refresh_devices(); + }); default_recorder = new RecorderProfile("default"); - await default_recorder.initialize(); + default_recorder.initialize().catch(error => { + log.error(LogCategory.AUDIO, tr("Failed to initialize default recorder: %o"), error); + }); sound.initialize().then(() => { log.info(LogCategory.AUDIO, tr("Sounds initialized")); diff --git a/shared/js/ui/modal/ModalPlaylistManage.ts b/shared/js/ui/modal/ModalPlaylistManage.ts new file mode 100644 index 00000000..e69de29b diff --git a/shared/js/voice/RecorderProfile.ts b/shared/js/voice/RecorderProfile.ts index 5108ad35..fcb3ffc3 100644 --- a/shared/js/voice/RecorderProfile.ts +++ b/shared/js/voice/RecorderProfile.ts @@ -51,8 +51,6 @@ class RecorderProfile { this.name = name; this.volatile = typeof(volatile) === "boolean" ? volatile : false; - this.initialize_input(); - this._ppt_hook = { callback_release: () => { if(this._ppt_timeout) @@ -80,18 +78,11 @@ class RecorderProfile { } async initialize() : Promise { - await this.load(); - await this.reinitialize_filter(); - //Why we started directly after initialize? - //After we connect to a server the ConnectionHandler will automatically - //start the VoiceRecorder as soon we've a voice bridge. - /* - try { - await this.input.start(); - } catch(error) { - console.warn(tr("Failed to start recorder after initialize (%o)"), error); - } - */ + audio.player.on_ready(async () => { + this.initialize_input(); + await this.load(); + await this.reinitialize_filter(); + }); } private initialize_input() { @@ -107,19 +98,6 @@ class RecorderProfile { if(this.callback_stop) this.callback_stop(); }; - - /* - this.input.callback_state_change = () => { - const new_state = this.input.current_state() === audio.recorder.InputState.RECORDING || this.input.current_state() === audio.recorder.InputState.DRY; - - if(new_state === this.record_supported) - return; - - this.record_supported = new_state; - if(this.callback_support_change) - this.callback_support_change(); - } - */ } private async load() { @@ -163,12 +141,13 @@ class RecorderProfile { } private save(enforce?: boolean) { - if(enforce || !this.volatile) { + if(enforce || !this.volatile) settings.changeGlobal(Settings.FN_PROFILE_RECORD(this.name), this.config); - } } private async reinitialize_filter() { + if(!this.input) return; + this.input.clear_filter(); if(this._ppt_hook_registered) { ppt.unregister_key_hook(this._ppt_hook);