2020-03-09 01:06:54 +08:00
|
|
|
import * as mpd from "./mpd.js";
|
|
|
|
|
|
|
|
export const escape = mpd.escape;
|
|
|
|
|
|
|
|
export function command(cmd) {
|
|
|
|
console.warn(`MOCK does not know "${cmd}"`);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function commandAndStatus(cmd) {
|
|
|
|
command(cmd);
|
|
|
|
return status();
|
|
|
|
}
|
|
|
|
|
|
|
|
export function status() {
|
|
|
|
return {
|
|
|
|
volume: 50,
|
|
|
|
elapsed: 10,
|
|
|
|
duration: 70,
|
|
|
|
file: "name.mp3",
|
|
|
|
Title: "Title of song",
|
|
|
|
Artist: "Artist of song",
|
|
|
|
Album: "Album of song",
|
|
|
|
Track: 6,
|
|
|
|
state: "play",
|
|
|
|
Id: 2
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function listQueue() {
|
|
|
|
return [
|
2020-03-10 05:24:31 +08:00
|
|
|
{Id:1, Track:5, Title:"Title 1", Artist:"AAA", Album:"BBB", duration:30},
|
2020-03-09 01:06:54 +08:00
|
|
|
status(),
|
2020-03-10 05:24:31 +08:00
|
|
|
{Id:3, Track:7, Title:"Title 3", Artist:"CCC", Album:"DDD", duration:230},
|
2020-03-09 01:06:54 +08:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function listPlaylists() {
|
2020-03-10 05:24:31 +08:00
|
|
|
return [
|
|
|
|
"Playlist 1",
|
|
|
|
"Playlist 2",
|
|
|
|
"Playlist 3"
|
|
|
|
];
|
2020-03-09 01:06:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
export async function enqueueByFilter(filter, sort = null) {
|
|
|
|
let tokens = ["findadd"];
|
|
|
|
tokens.push(serializeFilter(filter));
|
|
|
|
// sort && tokens.push("sort", sort); FIXME not implemented in MPD
|
|
|
|
return command(tokens.join(" "));
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function listPath(path) {
|
|
|
|
let lines = await command(`lsinfo "${escape(path)}"`);
|
|
|
|
return parser.pathContents(lines);
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function listTags(tag, filter = null) {
|
|
|
|
let tokens = ["list", tag];
|
|
|
|
if (filter) {
|
|
|
|
tokens.push(serializeFilter(filter));
|
|
|
|
|
|
|
|
let fakeGroup = Object.keys(filter)[0]; // FIXME hack for MPD < 0.21.6
|
|
|
|
tokens.push("group", fakeGroup);
|
|
|
|
}
|
|
|
|
let lines = await command(tokens.join(" "));
|
|
|
|
let parsed = parser.linesToStruct(lines);
|
|
|
|
return [].concat(tag in parsed ? parsed[tag] : []);
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function listSongs(filter, window = null) {
|
|
|
|
let tokens = ["find"];
|
|
|
|
tokens.push(serializeFilter(filter));
|
|
|
|
if (window) { tokens.push("window", window.join(":")); }
|
|
|
|
let lines = await command(tokens.join(" "));
|
|
|
|
return parser.songList(lines);
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function albumArt(songUrl) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function init() {}
|