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:
parent
a30c6ffc09
commit
d4164dfa72
@ -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) {
|
@objc func stateChanged(_ notification: Notification) {
|
||||||
guard let state = notification.userInfo?[Notification.stateKey] as? MPDClient.Status.State
|
guard let state = notification.userInfo?[Notification.stateKey] as? MPDClient.Status.State
|
||||||
else { return }
|
else { return }
|
||||||
|
|||||||
@ -22,8 +22,8 @@ class MPDClient {
|
|||||||
private let commandQueue = DispatchQueue(label: "commandQueue")
|
private let commandQueue = DispatchQueue(label: "commandQueue")
|
||||||
|
|
||||||
enum Command {
|
enum Command {
|
||||||
case prevTrack, nextTrack, playPause, stop, fetchStatus, fetchQueue,
|
case prevTrack, nextTrack, playPause, stop,
|
||||||
fetchAllAlbums
|
fetchStatus, fetchQueue, fetchAllAlbums
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Idle: OptionSet {
|
struct Idle: OptionSet {
|
||||||
@ -101,6 +101,14 @@ class MPDClient {
|
|||||||
queueCommand(command: .nextTrack)
|
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) {
|
func queueCommand(command: Command) {
|
||||||
noIdle()
|
noIdle()
|
||||||
commandQueue.async { [unowned self] in
|
commandQueue.async { [unowned self] in
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user