add support for opus audio mode AM_OPUS_OGG

This commit is contained in:
liamcottle 2024-06-05 12:24:20 +12:00
commit 4303e831e2

View file

@ -2868,6 +2868,11 @@
const audioMode = audioField.audio_mode;
const audioBytes = audioField.audio_bytes;
// handle opus: AM_OPUS_OGG
if(audioMode === 0x10){
return this.decodeOpusAudioToBlobUrl(audioField.audio_bytes);
}
// determine codec2 mode, or skip if unknown
const codecMode = this.lxmfAudioModeToCodec2ModeMap[audioMode];
if(!codecMode){
@ -2898,6 +2903,26 @@
return null;
}
},
async decodeOpusAudioToBlobUrl(audioBytes) {
try {
// convert base64 to uint8 array
const opusAudioBytes = this.base64ToArrayBuffer(audioBytes);
// create blob from opus audio
const blob = new Blob([opusAudioBytes], {
type: "audio/opus",
});
// create object url for blob
return URL.createObjectURL(blob);
} catch(e) {
// failed to decode opus audio
console.log(e);
return null;
}
},
},
computed: {
isMobile() {