summaryrefslogtreecommitdiff
path: root/media/playlist.go
diff options
context:
space:
mode:
Diffstat (limited to 'media/playlist.go')
-rw-r--r--media/playlist.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/media/playlist.go b/media/playlist.go
new file mode 100644
index 0000000..cf8edcf
--- /dev/null
+++ b/media/playlist.go
@@ -0,0 +1,19 @@
+package media
+
+// Playlist holds an array of videos capable of sorting by Timestamp.
+type Playlist []*Video
+
+// Len returns length of array (for sorting).
+func (p Playlist) Len() int {
+ return len(p)
+}
+
+// Swap swaps two values in array by index (for sorting).
+func (p Playlist) Swap(i, j int) {
+ p[i], p[j] = p[j], p[i]
+}
+
+// Less returns true if p[i] Timestamp is after p[j] (for sorting).
+func (p Playlist) Less(i, j int) bool {
+ return p[i].Timestamp.After(p[j].Timestamp)
+}