Prechádzať zdrojové kódy

Fixed Music player bug on PWA mode

Toby Chui 2 rokov pred
rodič
commit
884fb13d64
2 zmenil súbory, kde vykonal 11 pridanie a 9 odobranie
  1. 7 9
      web/Music/index.html
  2. 4 0
      web/script/ao_module.js

+ 7 - 9
web/Music/index.html

@@ -453,7 +453,7 @@
 
 	function returnToPreviousState(){
 		var inputFiles = ao_module_loadInputFiles();
-		if (inputFiles == null){
+		if (inputFiles == null || (inputFiles.path != undefined && inputFiles.pfp != undefined)){
 			//It doesn't seems like is an input file. 
 			//Fall back to legacy process
 			var hash = window.location.hash;
@@ -468,7 +468,7 @@
 				if (currentPath != ""){
 					//Create a dummy folder and trick the system to load to the previous states
 					var a = '<div></div>';
-					a = $(a).attr("filepath",currentPath);
+					a = $(a).attr("filepath",encodeURIComponent(currentPath));
 					openFolder(a[0],{
 						playIDAfterOpen: playingFileDetail[0],
 						startPaused: initPauseState}
@@ -2283,13 +2283,11 @@
 
 			//Check if auto playback is required. If yes, play it with the given filepath.
 			if (playIDAfterOpen != -1){
-				$(".mainList.item").each(function(){
-					if ($(this).attr("id") == playIDAfterOpen){
-						//This is the file that require to playback after the folder loaded
-						playSong($(this).find(".ts.header.selectable"),startPaused);
-						setTimeout(resizeQuickAdjust,500);
-					}
-				});
+				let targetSongItem = $("#" + playIDAfterOpen);
+				if (targetSongItem.length > 0){
+					playSong($(targetSongItem).find(".ui.header.selectable"),startPaused);
+					setTimeout(resizeQuickAdjust,500);
+				}
 			}
 
 			//Load thumbnail for song in list

+ 4 - 0
web/script/ao_module.js

@@ -126,6 +126,10 @@ function ao_module_loadInputFiles(){
         }
         var inputFileInfo = window.location.hash.substring(1,window.location.hash.length);
         inputFileInfo = JSON.parse(decodeURIComponent(inputFileInfo));
+
+        if (inputFileInfo.length == 0){
+            return null;
+        }
         return inputFileInfo
     }catch{
         return null;