mirror of
https://github.com/memen45/SubMusic.git
synced 2026-12-05 04:57:28 +01:00
added playables to store state in between sessions added shuffle to stored state added shuffle option to playlist options added podcast mode to play with persistent playback position
81 lines
2.4 KiB
MonkeyC
81 lines
2.4 KiB
MonkeyC
using Toybox.WatchUi;
|
|
|
|
module SubMusic {
|
|
module Menu {
|
|
|
|
class SongsLocal extends MenuBase {
|
|
|
|
private var d_ids;
|
|
|
|
function initialize(title, ids) {
|
|
MenuBase.initialize(title, true);
|
|
|
|
// load the menu items
|
|
d_ids = ids;
|
|
load();
|
|
}
|
|
|
|
function getItem(idx) {
|
|
|
|
// check if out of bounds
|
|
if (idx >= d_ids.size()) {
|
|
return null;
|
|
}
|
|
|
|
// load the menuitem
|
|
var id = d_ids[idx];
|
|
var isong = new ISong(id);
|
|
var meta = isong.metadata();
|
|
return new WatchUi.MenuItem(
|
|
meta.title, // label
|
|
meta.artist, // sublabel
|
|
id, // id
|
|
null
|
|
);
|
|
}
|
|
|
|
function load() {
|
|
|
|
// remove the non local songs
|
|
var todelete = [];
|
|
for (var idx = 0; idx != d_ids.size(); ++idx) {
|
|
var id = d_ids[idx];
|
|
var isong = new ISong(id);
|
|
|
|
// if not local, no menu entry is added
|
|
if (isong.refId() == null) {
|
|
todelete.add(id);
|
|
}
|
|
}
|
|
for (var idx = 0; idx != todelete.size(); ++idx) {
|
|
d_ids.remove(todelete[idx]);
|
|
}
|
|
}
|
|
}
|
|
|
|
class SongsLocalView extends MenuView {
|
|
function initialize(title) {
|
|
MenuView.initialize(new SongsLocal(title));
|
|
}
|
|
}
|
|
|
|
class SongsLocalDelegate extends MenuDelegate {
|
|
function initialize() {
|
|
MenuDelegate.initialize(method(:onSongSelect), null);
|
|
// ids are ids, so have to be handled, no onBack action
|
|
}
|
|
|
|
function onSongSelect(item) {
|
|
var id = item.getId();
|
|
// action onSongSelect should be defined by implementer classes
|
|
// future: default start playable with only this song
|
|
|
|
// store selection as current playlist/song
|
|
// SubMusic.NowPlaying.setSongId(id); // deprecated
|
|
|
|
// start the playback of this song
|
|
// Media.startPlayback(null); // nothing to start
|
|
}
|
|
}
|
|
}
|
|
} |