fix: Support audio in safari browser (#5943)
This commit is contained in:
parent
613fb0b064
commit
c9cae01cb4
3 changed files with 40 additions and 8 deletions
|
@ -23,6 +23,7 @@ import 'videojs-wavesurfer/dist/videojs.wavesurfer.js';
|
||||||
import 'videojs-record/dist/videojs.record.js';
|
import 'videojs-record/dist/videojs.record.js';
|
||||||
import 'videojs-record/dist/plugins/videojs.record.opus-recorder.js';
|
import 'videojs-record/dist/plugins/videojs.record.opus-recorder.js';
|
||||||
import { format, addSeconds } from 'date-fns';
|
import { format, addSeconds } from 'date-fns';
|
||||||
|
import { AUDIO_FORMATS } from 'shared/constants/messages';
|
||||||
|
|
||||||
WaveSurfer.microphone = MicrophonePlugin;
|
WaveSurfer.microphone = MicrophonePlugin;
|
||||||
|
|
||||||
|
@ -70,13 +71,26 @@ export default {
|
||||||
record: {
|
record: {
|
||||||
audio: true,
|
audio: true,
|
||||||
video: false,
|
video: false,
|
||||||
displayMilliseconds: false,
|
...(this.audioRecordFormat === AUDIO_FORMATS.WEBM && {
|
||||||
maxLength: 300,
|
monitorGain: 0,
|
||||||
audioEngine: 'opus-recorder',
|
recordingGain: 1,
|
||||||
audioWorkerURL: encoderWorker,
|
numberOfChannels: 1,
|
||||||
audioChannels: 1,
|
encoderSampleRate: 16000,
|
||||||
audioSampleRate: 48000,
|
originalSampleRateOverride: 16000,
|
||||||
audioBitRate: 128,
|
streamPages: true,
|
||||||
|
maxFramesPerPage: 1,
|
||||||
|
encoderFrameSize: 1,
|
||||||
|
encoderPath: 'opus-recorder/dist/waveWorker.min.js',
|
||||||
|
}),
|
||||||
|
...(this.audioRecordFormat === AUDIO_FORMATS.OGG && {
|
||||||
|
displayMilliseconds: false,
|
||||||
|
maxLength: 300,
|
||||||
|
audioEngine: 'opus-recorder',
|
||||||
|
audioWorkerURL: encoderWorker,
|
||||||
|
audioChannels: 1,
|
||||||
|
audioSampleRate: 48000,
|
||||||
|
audioBitRate: 128,
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -86,6 +100,12 @@ export default {
|
||||||
isRecording() {
|
isRecording() {
|
||||||
return this.player && this.player.record().isRecording();
|
return this.player && this.player.record().isRecording();
|
||||||
},
|
},
|
||||||
|
audioRecordFormat() {
|
||||||
|
if (this.isAWebWidgetInbox) {
|
||||||
|
return AUDIO_FORMATS.WEBM;
|
||||||
|
}
|
||||||
|
return AUDIO_FORMATS.OGG;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
window.Recorder = Recorder;
|
window.Recorder = Recorder;
|
||||||
|
|
|
@ -232,11 +232,18 @@ export default {
|
||||||
return this.showFileUpload || this.isNote;
|
return this.showFileUpload || this.isNote;
|
||||||
},
|
},
|
||||||
showAudioRecorderButton() {
|
showAudioRecorderButton() {
|
||||||
|
// Disable audio recorder for safari browser as recording is not supported
|
||||||
|
const isSafari = /^((?!chrome|android|crios|fxios).)*safari/i.test(
|
||||||
|
navigator.userAgent
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
this.isFeatureEnabledonAccount(
|
this.isFeatureEnabledonAccount(
|
||||||
this.accountId,
|
this.accountId,
|
||||||
FEATURE_FLAGS.VOICE_RECORDER
|
FEATURE_FLAGS.VOICE_RECORDER
|
||||||
) && this.showAudioRecorder
|
) &&
|
||||||
|
this.showAudioRecorder &&
|
||||||
|
!isSafari
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
showAudioPlayStopButton() {
|
showAudioPlayStopButton() {
|
||||||
|
|
|
@ -72,3 +72,8 @@ export const CSAT_RATINGS = [
|
||||||
color: '#44CE4B',
|
color: '#44CE4B',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
export const AUDIO_FORMATS = {
|
||||||
|
WEBM: 'audio/webm',
|
||||||
|
OGG: 'audio/ogg',
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in a new issue