Skip to content
Merged
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
15 changes: 13 additions & 2 deletions src/components/NewMessageForm/AudioRecorder/AudioRecorder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,13 @@ export default {
* Initialize the media stream and start capturing the audio
*/
async start() {
const useSafariFallback = MediaRecorder.isTypeSupported('video/mp4; codecs="mp4a.40.2"')

// Create new audio stream
try {
this.audioStream = await mediaDevicesManager.getUserMedia({
audio: true,
video: false,
})
} catch (exception) {
console.debug(exception)
Expand All @@ -176,7 +179,15 @@ export default {

// Create a mediarecorder to capture the stream
try {
this.mediaRecorder = new MediaRecorder(this.audioStream)
if (useSafariFallback) {
this.mediaRecorder = new MediaRecorder(this.audioStream, {
audioBitsPerSecond: 128000,
videoBitsPerSecond: 0,
mimeType: 'video/mp4; codecs="mp4a.40.2"',
})
} else {
this.mediaRecorder = new MediaRecorder(this.audioStream)
}
} catch (exception) {
console.debug(exception)
this.audioStream.getTracks().forEach(track => track.stop())
Expand All @@ -188,7 +199,7 @@ export default {
// Add event handler to onstop
this.mediaRecorder.onstop = this.generateFile

// Add event handler to ondataAvailable
// Add event handler to ondataavailable
this.mediaRecorder.ondataavailable = (e) => {
this.chunks.push(e.data)
}
Expand Down