This repository has been archived on 2019-06-23. You can view files and clone it, but cannot push or open issues or pull requests.
mumbledj/songqueue.go
2014-12-18 16:28:27 -08:00

38 lines
577 B
Go

/*
* MumbleDJ
* By Matthieu Grieger
* songqueue.go
* Copyright (c) 2014 Matthieu Grieger (MIT License)
*/
package main
type SongQueue struct {
queue *Queue
}
func NewSongQueue() *SongQueue {
return &SongQueue{
queue: NewQueue(),
}
}
func (q *SongQueue) AddSong(s *Song) bool {
beforeLen := q.queue.Len()
q.queue.Push(s)
if q.queue.Len() == beforeLen+1 {
return true
} else {
return false
}
return true
}
func (q *SongQueue) NextSong() *Song {
return q.queue.Poll().(*Song)
}
func (q *SongQueue) CurrentSong() *Song {
return q.queue.Peek().(*Song)
}