Add Support For Xiami .xm Files!

This commit is contained in:
MengYX
2020-04-23 20:46:08 +08:00
parent f2ea85bae9
commit 2526adcab0
3 changed files with 88 additions and 7 deletions

View File

@@ -7,11 +7,14 @@ export const WMA_HEADER = [
0x30, 0x26, 0xB2, 0x75, 0x8E, 0x66, 0xCF, 0x11,
0xA6, 0xD9, 0x00, 0xAA, 0x00, 0x62, 0xCE, 0x6C,
]
export const WAV_HEADER = [0x52, 0x49, 0x46, 0x46]
export const AudioMimeType = {
mp3: "audio/mpeg",
flac: "audio/flac",
m4a: "audio/mp4",
ogg: "audio/ogg"
ogg: "audio/ogg",
wma: "audio/x-ms-wma",
wav: "audio/x-wav"
};
// Also a new draft API: blob.arrayBuffer()
@@ -25,9 +28,9 @@ export async function GetArrayBuffer(blobObject) {
});
}
export function GetFileInfo(artist, title, filenameNoExt) {
export function GetFileInfo(artist, title, filenameNoExt, separator = "-") {
let newArtist = "", newTitle = "";
let filenameArray = filenameNoExt.split("-");
let filenameArray = filenameNoExt.split(separator);
if (filenameArray.length > 1) {
newArtist = filenameArray[0].trim();
newTitle = filenameArray[1].trim();
@@ -68,6 +71,7 @@ export function DetectAudioExt(data, fallbackExt) {
if (IsBytesEqual(OGG_HEADER, data.slice(0, OGG_HEADER.length))) return "ogg";
if (IsBytesEqual(M4A_HEADER, data.slice(4, 4 + M4A_HEADER.length))) return "m4a";
if (IsBytesEqual(WMA_HEADER, data.slice(0, WMA_HEADER.length))) return "wma";
if (IsBytesEqual(WAV_HEADER, data.slice(0, WAV_HEADER.length))) return "wav";
return fallbackExt;
}