beginning of work to save queue to server
This commit is contained in:
@@ -258,6 +258,11 @@ type SupportsSharing interface {
|
||||
CanShareArtists() bool
|
||||
}
|
||||
|
||||
type CanSavePlayQueue interface {
|
||||
SavePlayQueue(trackIDs []string, currentTrackPos int, timeSeconds int) error
|
||||
GetPlayQueue() (*SavedPlayQueue, error)
|
||||
}
|
||||
|
||||
type LyricsProvider interface {
|
||||
GetLyrics(track *Track) (*Lyrics, error)
|
||||
}
|
||||
|
||||
@@ -133,6 +133,12 @@ type LyricLine struct {
|
||||
Start float64 // seconds
|
||||
}
|
||||
|
||||
type SavedPlayQueue struct {
|
||||
Tracks []*Track
|
||||
TrackPos int
|
||||
TimePos int // seconds
|
||||
}
|
||||
|
||||
type ContentType int
|
||||
|
||||
const (
|
||||
|
||||
@@ -379,6 +379,27 @@ func (s *subsonicMediaProvider) GetLyrics(track *mediaprovider.Track) (*mediapro
|
||||
return mpLyrics, nil
|
||||
}
|
||||
|
||||
// CanSavePlayQueue interface
|
||||
|
||||
func (s *subsonicMediaProvider) SavePlayQueue(trackIDs []string, currentTrackPos int, timeSeconds int) error {
|
||||
return s.client.SavePlayQueue(trackIDs, map[string]string{
|
||||
"current": trackIDs[currentTrackPos],
|
||||
"position": strconv.Itoa(timeSeconds * 1000),
|
||||
})
|
||||
}
|
||||
|
||||
func (s *subsonicMediaProvider) GetPlayQueue() (*mediaprovider.SavedPlayQueue, error) {
|
||||
pq, err := s.client.GetPlayQueue()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
savedQueue := &mediaprovider.SavedPlayQueue{}
|
||||
savedQueue.Tracks = sharedutil.MapSlice(pq.Entries, toTrack)
|
||||
savedQueue.TrackPos = pq.Current
|
||||
savedQueue.TimePos = int(pq.Position)
|
||||
return savedQueue, nil
|
||||
}
|
||||
|
||||
func toTrack(ch *subsonic.Child) *mediaprovider.Track {
|
||||
if ch == nil {
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user