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

Small refactor and update time on connect

This commit is contained in:
Daniel Barber 2019-02-19 08:10:09 -05:00
parent f8ce8030b7
commit 212565ccd4
Signed by: danbarber
GPG Key ID: 931D8112E0103DD8
2 changed files with 13 additions and 16 deletions

View File

@ -49,17 +49,6 @@ class WindowController: NSWindowController {
setTransportControlState()
}
@objc func timeChanged(_ notification: Notification) {
guard let totalTime = notification.userInfo?[Notification.totalTimeKey] as? UInt,
let elapsedTimeMs = notification.userInfo?[Notification.elapsedTimeMsKey] as? UInt
else { return }
self.totalTime = totalTime
self.elapsedTimeMs = elapsedTimeMs
setTrackProgressControls()
}
func setTransportControlState() {
guard let state = state else { return }
@ -75,6 +64,17 @@ class WindowController: NSWindowController {
}
}
@objc func timeChanged(_ notification: Notification) {
guard let totalTime = notification.userInfo?[Notification.totalTimeKey] as? UInt,
let elapsedTimeMs = notification.userInfo?[Notification.elapsedTimeMsKey] as? UInt
else { return }
self.totalTime = totalTime
self.elapsedTimeMs = elapsedTimeMs
setTrackProgressControls()
}
func setTrackProgressControls() {
guard let totalTime = totalTime,
let elapsedTimeMs = elapsedTimeMs
@ -83,11 +83,7 @@ class WindowController: NSWindowController {
trackProgressBar.maxValue = Double(totalTime * 1000)
trackProgressBar.integerValue = Int(elapsedTimeMs)
if [.playing, .paused].contains(state) {
trackProgressBar.isEnabled = true
} else {
trackProgressBar.isEnabled = false
}
trackProgressBar.isEnabled = [.playing, .paused].contains(state)
if state == .playing {
trackTimer?.invalidate()

View File

@ -61,6 +61,7 @@ class MPDClient {
fetchAllAlbums()
self.delegate?.didUpdateState(mpdClient: self, state: self.status!.state)
self.delegate?.didUpdateTime(mpdClient: self, total: self.status!.totalTime, elapsedMs: self.status!.elapsedTimeMs)
self.delegate?.didUpdateQueue(mpdClient: self, queue: self.queue)
self.delegate?.didUpdateQueuePos(mpdClient: self, song: self.status!.song)
idle()