Jelajahi Sumber

Fixed Audio module 7ki 7ki bang bang bug

Toby Chui 3 tahun lalu
induk
melakukan
46138b606b
2 mengubah file dengan 25 tambahan dan 1 penghapusan
  1. 6 1
      web/Music/embedded.html
  2. 19 0
      web/Music/functions/getMeta.js

+ 6 - 1
web/Music/embedded.html

@@ -218,6 +218,11 @@
 					ao_module_setWindowTitle(data[i][0]);
 				}
 			}
+
+			if (data.length == 0){
+				//Error occured
+				player.src = "../media?file=" + encodeURIComponent(playingFileInfo.filepath);
+			}
 			
 			//Load song title into the display area
 			updateDisplayInformation(songInfo[0],songInfo[3]);
@@ -227,7 +232,7 @@
 			
 			//Initiate the current playSong in the songList
 			updatePlayingSongSelection();
-		})
+		});
 		/*
 		$.get("../Music/getMeta?file=" + encodeURIComponent(playingFileInfo.filepath),function(data){
 			//console.log(data);

+ 19 - 0
web/Music/functions/getMeta.js

@@ -50,6 +50,25 @@ if (requirelib("filelib") == true){
             }
         }
     }
+
+    if (nearbyFiles == false || nearbyFiles.length == 0){
+        //There are some error that unable to scan nearby files. Return this file info only.
+        audioFiles = [];
+        var thisFile = openingFilePath;
+        var ext = thisFile.split(".").pop();
+        var fileExt = ext.substr(1);
+        var fileName = thisFile.split("/").pop();
+        var fileSize = filelib.filesize(thisFile);
+        var humanReadableFileSize = bytesToSize(fileSize);
+
+        var thisFileInfo = [];
+        thisFileInfo.push(fileName);
+        thisFileInfo.push(thisFile);
+        thisFileInfo.push(fileExt);
+        thisFileInfo.push(humanReadableFileSize);
+
+        audioFiles.push(thisFileInfo);
+    }
     sendJSONResp(JSON.stringify(audioFiles));
 }