Browse Source

fix: await call to audio.play()

Fela Maslen 5 years ago
parent
commit
1ad6ecae0c
1 changed files with 6 additions and 2 deletions
  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(() => {