mirror of
https://github.com/danbee/persephone
synced 2025-03-04 08:39:11 +00:00
Fix some issues with system Now Playing
This commit is contained in:
parent
1135a96f38
commit
d39a2aa78b
@ -14,7 +14,7 @@ import Kingfisher
|
|||||||
class MediaInfoController {
|
class MediaInfoController {
|
||||||
init() {
|
init() {
|
||||||
App.store.subscribe(self) {
|
App.store.subscribe(self) {
|
||||||
$0.select { $0.playerState.currentSong }
|
$0.select { $0.playerState }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,10 +66,10 @@ class MediaInfoController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extension MediaInfoController: StoreSubscriber {
|
extension MediaInfoController: StoreSubscriber {
|
||||||
typealias StoreSubscriberStateType = Song?
|
typealias StoreSubscriberStateType = PlayerState?
|
||||||
|
|
||||||
func newState(state: StoreSubscriberStateType) {
|
func newState(state: StoreSubscriberStateType) {
|
||||||
guard let song = state else {return}
|
guard let song = state?.currentSong else { return }
|
||||||
|
|
||||||
notifyTrack(song)
|
notifyTrack(song)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,11 +12,13 @@ import MediaPlayer
|
|||||||
import Kingfisher
|
import Kingfisher
|
||||||
|
|
||||||
class PlayerStateInfoController {
|
class PlayerStateInfoController {
|
||||||
|
let commandCenter = MPRemoteCommandCenter.shared()
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
App.store.subscribe(self) {
|
App.store.subscribe(self) {
|
||||||
$0.select { $0.playerState.state }
|
$0.select { $0.playerState.state }
|
||||||
}
|
}
|
||||||
let commandCenter = MPRemoteCommandCenter.shared()
|
|
||||||
commandCenter.playCommand.addTarget { _ in
|
commandCenter.playCommand.addTarget { _ in
|
||||||
App.mpdClient.playPause()
|
App.mpdClient.playPause()
|
||||||
return .success
|
return .success
|
||||||
@ -39,6 +41,13 @@ class PlayerStateInfoController {
|
|||||||
App.mpdClient.prevTrack()
|
App.mpdClient.prevTrack()
|
||||||
return .success
|
return .success
|
||||||
}
|
}
|
||||||
|
|
||||||
|
commandCenter.changePlaybackPositionCommand.addTarget { event in
|
||||||
|
let changeEvent = event as! MPChangePlaybackPositionCommandEvent
|
||||||
|
|
||||||
|
App.mpdClient.seekCurrentSong(timeInSeconds: Float(changeEvent.positionTime))
|
||||||
|
return .success
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func notifyState(_ state: MPDClient.MPDStatus.State?) {
|
func notifyState(_ state: MPDClient.MPDStatus.State?) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user