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-27 00:25:49 -08:00

41 lines
612 B
Go

/*
* MumbleDJ
* By Matthieu Grieger
* songqueue.go
* Copyright (c) 2014 Matthieu Grieger (MIT License)
*/
package main
import (
"errors"
)
type SongQueue struct {
queue *Queue
}
func NewSongQueue() *SongQueue {
return &SongQueue{
queue: NewQueue(),
}
}
func (q *SongQueue) AddSong(s *Song) error {
beforeLen := q.queue.Len()
q.queue.Push(s)
if q.queue.Len() == beforeLen+1 {
return nil
} else {
return errors.New("Could not add Song to the SongQueue.")
}
}
func (q *SongQueue) NextSong() *Song {
return q.queue.Poll().(*Song)
}
func (q *SongQueue) Len() int {
return q.queue.Len()
}