cyp/app/js/mpd-mock.js

77 lines
1.4 KiB
JavaScript
Raw Normal View History

2020-03-09 01:06:54 +08:00
export function command(cmd) {
2020-03-11 05:11:36 +08:00
console.warn(`mpd-mock does not know "${cmd}"`);
2020-03-09 01:06:54 +08:00
}
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",
2020-03-14 06:01:16 +08:00
Track: "6",
2020-03-09 01:06:54 +08:00
state: "play",
Id: 2
}
}
export function listQueue() {
return [
2020-03-15 05:40:11 +08:00
{Id:1, Track:"5", Title:"Title 1", Artist:"AAA", Album:"BBB", duration:30, file:"a.mp3"},
2020-03-09 01:06:54 +08:00
status(),
2020-03-15 05:40:11 +08:00
{Id:3, Track:"7", Title:"Title 3", Artist:"CCC", Album:"DDD", duration:230, file:"c.mp3"},
2020-03-09 01:06:54 +08:00
];
}
2020-03-13 06:03:26 +08:00
export 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
}
2020-03-13 06:03:26 +08:00
export function listPath(path) {
return {
"directory": [
{"directory": "Dir 1"},
{"directory": "Dir 2"},
{"directory": "Dir 3"}
],
"file": [
{"file": "File 1"},
{"file": "File 2"},
{"file": "File 3"}
]
}
2020-03-09 01:06:54 +08:00
}
2020-03-13 06:03:26 +08:00
export function listTags(tag, filter = null) {
2020-03-12 05:46:28 +08:00
switch (tag) {
case "AlbumArtist": return ["Artist 1", "Artist 2", "Artist 3"];
case "Album": return ["Album 1", "Album 2", "Album 3"];
2020-03-09 01:06:54 +08:00
}
}
2020-03-13 06:03:26 +08:00
export function listSongs(filter, window = null) {
return listQueue();
2020-03-09 01:06:54 +08:00
}
2020-03-14 06:01:16 +08:00
export function searchSongs(filter) {
return listQueue();
}
2020-03-13 06:03:26 +08:00
export function albumArt(songUrl) {
2020-03-15 05:45:07 +08:00
return new Promise(resolve => setTimeout(resolve, 1000));
2020-03-09 01:06:54 +08:00
return null;
}
export function init() {}