Pārlūkot izejas kodu

fix: await call to audio.play()

Fela Maslen 5 gadi atpakaļ
vecāks
revīzija
1ad6ecae0c
1 mainītis faili ar 6 papildinājumiem un 2 dzēšanām
  1. 6 2
      gmus-web/src/components/player.tsx

+ 6 - 2
gmus-web/src/components/player.tsx

@@ -82,8 +82,12 @@ export const Player: React.FC<Props> = ({
     );
   }, []);
 
-  const play = useCallback(() => {
-    audio.current?.play();
+  const play = useCallback(async () => {
+    try {
+      await audio.current?.play();
+    } catch {
+      // pass
+    }
   }, []);
 
   const pause = useCallback(() => {