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

38 lines
577 B
Go
Raw Normal View History

2014-12-15 06:37:55 +01:00
/*
* MumbleDJ
* By Matthieu Grieger
* songqueue.go
* Copyright (c) 2014 Matthieu Grieger (MIT License)
*/
package main
2014-12-15 06:37:55 +01:00
type SongQueue struct {
queue *Queue
}
2014-12-15 06:37:55 +01:00
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)
}