Skip to content

Commit 1db7565

Browse files
Merge pull request #6014 from nextcloud/backport/5970/stable22
[stable22] Wait for the wav encoder to be initialized before allowing recordings
2 parents ad2e155 + b74ae5e commit 1db7565

File tree

3 files changed

+62
-0
lines changed

3 files changed

+62
-0
lines changed

src/components/NewMessageForm/AudioRecorder/AudioRecorder.vue

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
content: startRecordingTooltip,
2929
delay: tooltipDelay,
3030
}"
31+
:disabled="!encoderReady"
3132
class="audio-recorder__trigger nc-button nc-button__main"
3233
@click="start">
3334
<Microphone
@@ -146,6 +147,10 @@ export default {
146147
abortRecordingTooltip() {
147148
return t('spreed', 'Dismiss recording')
148149
},
150+
151+
encoderReady() {
152+
return this.$store.getters.encoderReady
153+
},
149154
},
150155
151156
watch: {
@@ -155,6 +160,10 @@ export default {
155160
},
156161
},
157162
163+
mounted() {
164+
this.$store.dispatch('initializeAudioEncoder')
165+
},
166+
158167
beforeDestroy() {
159168
this.killStreams()
160169
},

src/store/audioRecorderStore.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/**
2+
* @copyright Copyright (c) 2021 Marco Ambrosini <[email protected]>
3+
*
4+
* @author Marco Ambrosini <[email protected]>
5+
*
6+
* @license GNU AGPL version 3 or any later version
7+
*
8+
* This program is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU Affero General Public License as
10+
* published by the Free Software Foundation, either version 3 of the
11+
* License, or (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU Affero General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU Affero General Public License
19+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
20+
*
21+
*/
22+
23+
import { register } from 'extendable-media-recorder'
24+
import { connect } from 'extendable-media-recorder-wav-encoder'
25+
26+
const state = () => ({
27+
encoderReady: false,
28+
})
29+
30+
const getters = {
31+
encoderReady: state => {
32+
return state.encoderReady
33+
},
34+
}
35+
36+
const mutations = {
37+
encoderReady: (state) => {
38+
state.encoderReady = true
39+
},
40+
}
41+
42+
const actions = {
43+
async initializeAudioEncoder({ commit, state }) {
44+
if (!state.encoderReady) {
45+
register(await connect())
46+
commit('encoderReady')
47+
}
48+
},
49+
}
50+
51+
export default { state, mutations, getters, actions }

src/store/storeConfig.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
*/
2222

2323
import actorStore from './actorStore'
24+
import audioRecorderStore from './audioRecorderStore'
2425
import callViewStore from './callViewStore'
2526
import conversationsStore from './conversationsStore'
2627
import fileUploadStore from './fileUploadStore'
@@ -40,6 +41,7 @@ import messageActionsStore from './messageActionsStore'
4041
export default {
4142
modules: {
4243
actorStore,
44+
audioRecorderStore,
4345
callViewStore,
4446
conversationsStore,
4547
fileUploadStore,

0 commit comments

Comments
 (0)