aboutsummaryrefslogtreecommitdiff
path: root/playlist.go
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2023-07-21 10:50:07 +0200
committerFlorian Fischer <florian.fischer@muhq.space>2023-07-21 10:50:07 +0200
commit9cb08df11d7446357c5d480d08d256b906d4988e (patch)
tree23bfd03aecb715a59892e7bbeb64cb5368771276 /playlist.go
parentc2ba7e49b2095019f9a7df2d71bb4b42b31a357e (diff)
downloadWRMS-9cb08df11d7446357c5d480d08d256b906d4988e.tar.gz
WRMS-9cb08df11d7446357c5d480d08d256b906d4988e.zip
implement playlist in order traversal
This ensures that the initial reported song array is in order.
Diffstat (limited to 'playlist.go')
-rw-r--r--playlist.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/playlist.go b/playlist.go
index becc85e..1fbd344 100644
--- a/playlist.go
+++ b/playlist.go
@@ -61,3 +61,16 @@ func (pl *Playlist) RemoveSong(s *Song) {
heap.Remove(pl, s.index)
llog.DDebug("removing song %p in the playlist (%p) -> %v", s, pl, pl)
}
+
+func (pl *Playlist) OrderedList() []*Song {
+ songs := make([]*Song, 0, pl.Len())
+
+ cpy := make(Playlist, 0, pl.Len())
+ copy(cpy, *pl)
+
+ for cpy.Len() > 0 {
+ songs = append(songs, heap.Pop(&cpy).(*Song))
+ }
+
+ return songs
+}