Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/components/NewMessageForm/AudioRecorder/AudioRecorder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
content: startRecordingTooltip,
delay: tooltipDelay,
}"
:disabled="!encoderReady"
class="audio-recorder__trigger nc-button nc-button__main"
@click="start">
<Microphone
Expand Down Expand Up @@ -146,6 +147,10 @@ export default {
abortRecordingTooltip() {
return t('spreed', 'Dismiss recording')
},

encoderReady() {
return this.$store.getters.encoderReady
},
},

watch: {
Expand All @@ -155,6 +160,10 @@ export default {
},
},

mounted() {
this.$store.dispatch('initializeAudioEncoder')
},

beforeDestroy() {
this.killStreams()
},
Expand Down
51 changes: 51 additions & 0 deletions src/store/audioRecorderStore.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* @copyright Copyright (c) 2021 Marco Ambrosini <[email protected]>
*
* @author Marco Ambrosini <[email protected]>
*
* @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 = () => ({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

am wondering if we need a generic store category for that.
having a specific store submodule just for this feels a bit overkill

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you have in mind?

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 }
2 changes: 2 additions & 0 deletions src/store/storeConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
*/

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