Wait for the wav encoder to be initialized bedore allowing recordings

Signed-off-by: Marco Ambrosini <marcoambrosini@pm.me>
This commit is contained in:
Marco Ambrosini 2021-07-14 10:51:13 +02:00
Родитель f58a263868
Коммит 24e3f6ffcb
3 изменённых файлов: 62 добавлений и 0 удалений

Просмотреть файл

@ -28,6 +28,7 @@
content: startRecordingTooltip,
delay: tooltipDelay,
}"
:disabled="!encoderReady"
class="audio-recorder__trigger nc-button nc-button__main"
@click="start">
<Microphone
@ -146,6 +147,10 @@ export default {
abortRecordingTooltip() {
return t('spreed', 'Dismiss recording')
},
encoderReady() {
return this.$store.getters.encoderReady
},
},
watch: {
@ -155,6 +160,10 @@ export default {
},
},
mounted() {
this.$store.dispatch('initializeAudioEncoder')
},
beforeDestroy() {
this.killStreams()
},

Просмотреть файл

@ -0,0 +1,51 @@
/**
* @copyright Copyright (c) 2021 Marco Ambrosini <marcoambrosini@pm.me>
*
* @author Marco Ambrosini <marcoambrosini@pm.me>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
import { register } from 'extendable-media-recorder'
import { connect } from 'extendable-media-recorder-wav-encoder'
const state = () => ({
encoderReady: false,
})
const getters = {
encoderReady: state => {
return state.encoderReady
},
}
const mutations = {
encoderReady: (state) => {
state.encoderReady = true
},
}
const actions = {
async initializeAudioEncoder({ commit, state }) {
if (!state.encoderReady) {
register(await connect())
commit('encoderReady')
}
},
}
export default { state, mutations, getters, actions }

Просмотреть файл

@ -21,6 +21,7 @@
*/
import actorStore from './actorStore'
import audioRecorderStore from './audioRecorderStore'
import callViewStore from './callViewStore'
import conversationsStore from './conversationsStore'
import fileUploadStore from './fileUploadStore'
@ -40,6 +41,7 @@ import messageActionsStore from './messageActionsStore'
export default {
modules: {
actorStore,
audioRecorderStore,
callViewStore,
conversationsStore,
fileUploadStore,