Files
SubMusic/source/View/SubMusicMenuSongsLocal.mc
memen45 b900e8cade fixed charge blocked on auto sync hang
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
2021-01-19 20:07:47 +01:00

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
}
}
}
}