Use Universal Mask for Qmc,Mgg,Mflac
Add Local Experimental Support For Mgg
This commit is contained in:
@@ -1,7 +1,13 @@
|
||||
export {GetArrayBuffer, GetFileInfo, GetCoverURL, AudioMimeType}
|
||||
export const AudioMimeType = {
|
||||
mp3: "audio/mpeg",
|
||||
flac: "audio/flac",
|
||||
m4a: "audio/mp4",
|
||||
ogg: "audio/ogg"
|
||||
};
|
||||
export const FLAC_HEADER = [0x66, 0x4C, 0x61, 0x43, 0x00];
|
||||
|
||||
// Also a new draft API: blob.arrayBuffer()
|
||||
async function GetArrayBuffer(blobObject) {
|
||||
export async function GetArrayBuffer(blobObject) {
|
||||
return await new Promise(resolve => {
|
||||
const reader = new FileReader();
|
||||
reader.onload = (e) => {
|
||||
@@ -11,14 +17,7 @@ async function GetArrayBuffer(blobObject) {
|
||||
});
|
||||
}
|
||||
|
||||
const AudioMimeType = {
|
||||
mp3: "audio/mpeg",
|
||||
flac: "audio/flac",
|
||||
m4a: "audio/mp4",
|
||||
ogg: "audio/ogg"
|
||||
};
|
||||
|
||||
function GetFileInfo(artist, title, filenameNoExt) {
|
||||
export function GetFileInfo(artist, title, filenameNoExt) {
|
||||
let newArtist = "", newTitle = "";
|
||||
let filenameArray = filenameNoExt.split("-");
|
||||
if (filenameArray.length > 1) {
|
||||
@@ -28,19 +27,15 @@ function GetFileInfo(artist, title, filenameNoExt) {
|
||||
newTitle = filenameArray[0].trim();
|
||||
}
|
||||
|
||||
if (typeof artist == "string" && artist !== "") {
|
||||
newArtist = artist;
|
||||
}
|
||||
if (typeof title == "string" && title !== "") {
|
||||
newTitle = title;
|
||||
}
|
||||
if (typeof artist == "string" && artist !== "") newArtist = artist;
|
||||
if (typeof title == "string" && title !== "") newTitle = title;
|
||||
return {artist: newArtist, title: newTitle};
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
function GetCoverURL(metadata) {
|
||||
export function GetCoverURL(metadata) {
|
||||
let pic_url = "";
|
||||
if (metadata.common.picture !== undefined && metadata.common.picture.length > 0) {
|
||||
let pic = new Blob([metadata.common.picture[0].data], {type: metadata.common.picture[0].format});
|
||||
@@ -48,3 +43,9 @@ function GetCoverURL(metadata) {
|
||||
}
|
||||
return pic_url;
|
||||
}
|
||||
|
||||
export function IsBytesEqual(first, second) {
|
||||
return first.every((val, idx) => {
|
||||
return val === second[idx];
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user