From 35be6cc4665ce88edd58077f05021825f68eae85 Mon Sep 17 00:00:00 2001 From: Olga Bulat Date: Fri, 12 Apr 2024 08:15:09 +0300 Subject: [PATCH] Handle global audio play errors (#4011) * Fix audio errors Signed-off-by: Olga Bulat * Update frontend/src/components/VAudioTrack/VGlobalAudioTrack.vue * Update frontend/src/utils/sentry-config.ts --------- Signed-off-by: Olga Bulat --- .../components/VAudioTrack/VAudioTrack.vue | 32 ++----------------- .../VAudioTrack/VGlobalAudioTrack.vue | 15 +++++---- frontend/src/constants/audio.ts | 5 +++ frontend/src/stores/active-media.ts | 20 ++++++++++++ .../AudioTrack/v-audio-track.spec.js | 8 ++--- 5 files changed, 39 insertions(+), 41 deletions(-) diff --git a/frontend/src/components/VAudioTrack/VAudioTrack.vue b/frontend/src/components/VAudioTrack/VAudioTrack.vue index 340d5ac9c2f..8c5e89b1523 100644 --- a/frontend/src/components/VAudioTrack/VAudioTrack.vue +++ b/frontend/src/components/VAudioTrack/VAudioTrack.vue @@ -57,7 +57,7 @@ import { ref, watch, } from "vue" -import { useContext, useRoute } from "@nuxtjs/composition-api" +import { useRoute } from "@nuxtjs/composition-api" import { useActiveAudio } from "~/composables/use-active-audio" import { defaultRef } from "~/composables/default-ref" @@ -154,7 +154,6 @@ export default defineComponent({ }, setup(props, { emit }) { const i18n = useI18n() - const { $sentry } = useContext() const activeMediaStore = useActiveMediaStore() const route = useRoute() @@ -363,34 +362,7 @@ export default defineComponent({ if (!localAudio) { initLocalAudio() } - - const playPromise = localAudio?.play() - // Check if the audio can be played successfully - if (playPromise !== undefined) { - playPromise.catch((err) => { - let message: string - switch (err.name) { - case "NotAllowedError": { - message = "err_unallowed" - break - } - case "NotSupportedError": { - message = "err_unsupported" - break - } - case "AbortError": { - message = "err_aborted" - break - } - default: { - message = "err_unknown" - $sentry.captureException(err) - } - } - activeMediaStore.setMessage({ message }) - localAudio?.pause() - }) - } + activeMediaStore.playAudio(localAudio) } const pause = () => localAudio?.pause() diff --git a/frontend/src/components/VAudioTrack/VGlobalAudioTrack.vue b/frontend/src/components/VAudioTrack/VGlobalAudioTrack.vue index 12ea0fdc6fa..2e59bd3e4ef 100644 --- a/frontend/src/components/VAudioTrack/VGlobalAudioTrack.vue +++ b/frontend/src/components/VAudioTrack/VGlobalAudioTrack.vue @@ -33,7 +33,8 @@