mirror of
https://github.com/danbee/persephone
synced 2025-03-04 08:39:11 +00:00
Fix a few things that got forgotten during the refactor
This commit is contained in:
parent
9517abf319
commit
487e0cc2c2
@ -36,7 +36,7 @@ class QueueViewController: NSViewController,
|
||||
let newQueuePos = queueView.selectedRow - 1
|
||||
|
||||
if newQueuePos >= 0 {
|
||||
AppDelegate.mpdClient.playTrack(queuePos: newQueuePos)
|
||||
AppDelegate.mpdClient.playTrack(at: newQueuePos)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -24,12 +24,22 @@ extension MPDClient {
|
||||
sendStop()
|
||||
case .playPause:
|
||||
sendPlay()
|
||||
case .seekCurrentSong:
|
||||
guard let timeInSeconds = userData["timeInSeconds"] as? Float
|
||||
else { return }
|
||||
sendSeekCurrentSong(timeInSeconds: timeInSeconds)
|
||||
|
||||
// Status commands
|
||||
case .fetchStatus:
|
||||
sendRunStatus()
|
||||
|
||||
// Queue commands
|
||||
case .fetchQueue:
|
||||
sendFetchQueue()
|
||||
case .playTrack:
|
||||
guard let queuePos = userData["queuePos"] as? Int
|
||||
else { return }
|
||||
sendPlayTrack(at: queuePos)
|
||||
|
||||
// Album commands
|
||||
case .fetchAllAlbums:
|
||||
|
||||
@ -14,16 +14,12 @@ extension MPDClient {
|
||||
sendCommand(command: .fetchQueue)
|
||||
}
|
||||
|
||||
func playTrack(queuePos: Int) {
|
||||
guard isConnected else { return }
|
||||
func playTrack(at queuePos: Int) {
|
||||
queueCommand(command: .playTrack, userData: ["queuePos": queuePos])
|
||||
}
|
||||
|
||||
noIdle()
|
||||
let commandOperation = BlockOperation { [unowned self] in
|
||||
mpd_run_play_pos(self.connection, UInt32(queuePos))
|
||||
}
|
||||
commandOperation.queuePriority = .veryHigh
|
||||
commandQueue.addOperation(commandOperation)
|
||||
idle()
|
||||
func sendPlayTrack(at queuePos: Int) {
|
||||
mpd_run_play_pos(self.connection, UInt32(queuePos))
|
||||
}
|
||||
|
||||
func sendFetchQueue() {
|
||||
|
||||
@ -27,11 +27,10 @@ extension MPDClient {
|
||||
}
|
||||
|
||||
func seekCurrentSong(timeInSeconds: Float) {
|
||||
noIdle()
|
||||
commandQueue.addOperation { [unowned self] in
|
||||
mpd_run_seek_current(self.connection, timeInSeconds, false)
|
||||
}
|
||||
idle()
|
||||
queueCommand(
|
||||
command: .seekCurrentSong,
|
||||
userData: ["timeInSeconds": timeInSeconds]
|
||||
)
|
||||
}
|
||||
|
||||
func sendNextTrack() {
|
||||
@ -62,4 +61,7 @@ extension MPDClient {
|
||||
}
|
||||
}
|
||||
|
||||
func sendSeekCurrentSong(timeInSeconds: Float) {
|
||||
mpd_run_seek_current(self.connection, timeInSeconds, false)
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,8 +22,8 @@ class MPDClient {
|
||||
var commandsQueued: UInt = 0
|
||||
|
||||
enum Command {
|
||||
case prevTrack, nextTrack, playPause, stop,
|
||||
fetchStatus, fetchQueue, fetchAllAlbums,
|
||||
case prevTrack, nextTrack, playPause, stop, seekCurrentSong,
|
||||
fetchStatus, fetchQueue, playTrack, fetchAllAlbums,
|
||||
playAlbum, getAlbumURI
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user