mirror of
https://github.com/danbee/persephone
synced 2025-03-04 08:39:11 +00:00
* Use the OperationQueue's `operationCount` function instead of keeping count ourselves. This is reliable now each command is entirely self contained. * Rename `queueCommand` to `enqueueCommand` * Move the command Enum into its own model file * Move the `enqueueCommand` function into MPDClient+Command
35 lines
693 B
Swift
35 lines
693 B
Swift
//
|
|
// Queue.swift
|
|
// Persephone
|
|
//
|
|
// Created by Daniel Barber on 2019/3/15.
|
|
// Copyright © 2019 Dan Barber. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
import mpdclient
|
|
|
|
extension MPDClient {
|
|
func fetchQueue() {
|
|
sendCommand(command: .fetchQueue)
|
|
}
|
|
|
|
func playTrack(at queuePos: Int) {
|
|
enqueueCommand(command: .playTrack, userData: ["queuePos": queuePos])
|
|
}
|
|
|
|
func sendPlayTrack(at queuePos: Int) {
|
|
mpd_run_play_pos(self.connection, UInt32(queuePos))
|
|
}
|
|
|
|
func sendFetchQueue() {
|
|
self.queue = []
|
|
mpd_send_list_queue_meta(connection)
|
|
|
|
while let mpdSong = mpd_recv_song(connection) {
|
|
let song = Song(mpdSong)
|
|
self.queue.append(song)
|
|
}
|
|
}
|
|
}
|