Explorar o código

fix: await call to audio.play()

Fela Maslen %!s(int64=5) %!d(string=hai) anos
pai
achega
1ad6ecae0c
Modificáronse 1 ficheiros con 6 adicións e 2 borrados
  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(() => {