gemercheung 1 gadu atpakaļ
vecāks
revīzija
09389808e3
1 mainītis faili ar 9 papildinājumiem un 5 dzēšanām
  1. 9 5
      packages/qjkankan-view/src/hooks/useAudio.js

+ 9 - 5
packages/qjkankan-view/src/hooks/useAudio.js

@@ -47,8 +47,8 @@ async function initDefaultAudio() {
   );
 
   watch(
-    currentAudio,
-    (val) => {
+    [currentAudio, currentScene],
+    ([val, ns], [_, os]) => {
       const oldValue = currentAudioTemp.value;
       const newValue = unref(val).url;
       const isSame = newValue === oldValue;
@@ -64,12 +64,16 @@ async function initDefaultAudio() {
             currentAudioTemp.value = newValue;
           } else {
             //相同URL的再次播放
+            const isSwitch = ns.sceneCode !== os.sceneCode;
             if (unref(currentPlayer).isPlaying) {
-              console.log("相同URL切换时在播放");
+              console.log("相同URL切换时在播放", isSwitch);
+              unref(currentPlayer).resume();
             } else {
-              console.log("相同URL切换时暂停");
+              if (!isSwitch) {
+                console.log("相同URL没切换时toggle", isSwitch);
+                unref(currentPlayer).resume();
+              }
             }
-            unref(currentPlayer).resume();
           }
         }
       } else {