1
1
mirror of https://github.com/danbee/persephone synced 2025-03-04 08:39:11 +00:00

Double clicking on a track in the queue plays it

This commit is contained in:
Daniel Barber 2019-02-13 21:24:32 -05:00
parent a30c6ffc09
commit d4164dfa72
Signed by: danbarber
GPG Key ID: 931D8112E0103DD8
2 changed files with 19 additions and 2 deletions

View File

@ -52,6 +52,15 @@ class QueueViewController: NSViewController, NSOutlineViewDataSource, NSOutlineV
)
}
@IBAction func playTrack(_ sender: Any) {
guard let view = sender as? NSOutlineView
else { return }
let queuePos = view.selectedRow - 1
AppDelegate.mpdClient.playTrack(queuePos: queuePos)
}
@objc func stateChanged(_ notification: Notification) {
guard let state = notification.userInfo?[Notification.stateKey] as? MPDClient.Status.State
else { return }

View File

@ -22,8 +22,8 @@ class MPDClient {
private let commandQueue = DispatchQueue(label: "commandQueue")
enum Command {
case prevTrack, nextTrack, playPause, stop, fetchStatus, fetchQueue,
fetchAllAlbums
case prevTrack, nextTrack, playPause, stop,
fetchStatus, fetchQueue, fetchAllAlbums
}
struct Idle: OptionSet {
@ -101,6 +101,14 @@ class MPDClient {
queueCommand(command: .nextTrack)
}
func playTrack(queuePos: Int) {
noIdle()
commandQueue.async { [unowned self] in
mpd_run_play_pos(self.connection, UInt32(queuePos))
}
idle()
}
func queueCommand(command: Command) {
noIdle()
commandQueue.async { [unowned self] in