Skip to content

Commit 4dbb52a

Browse files
committed
Adds NotificationCenter observer for changes in "now playing" item, so changing tracks in Apple Music updates the PineTime interface. Also added handling for "224" code sent by InfiniTime music app on open to update the interface with relevant data the second the app is opened on the watch.
1 parent 9634203 commit 4dbb52a

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

InfiniLink/Music/MusicController.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class MusicController {
3636
init() {
3737
musicPlayer.beginGeneratingPlaybackNotifications()
3838
NotificationCenter.default.addObserver(self, selector: #selector(self.onNotificationReceipt(_:)), name: .MPMusicPlayerControllerPlaybackStateDidChange, object: nil)
39+
NotificationCenter.default.addObserver(self, selector: #selector(self.onNotificationReceipt(_:)), name: .MPMusicPlayerControllerNowPlayingItemDidChange, object: nil)
3940
}
4041

4142
@objc func onNotificationReceipt(_ notification: Notification) {
@@ -69,6 +70,8 @@ class MusicController {
6970
if volume + (1 / volumeSlots) > 1.0 {MPVolumeView.setVolume(1.0)} else {MPVolumeView.setVolume(volume + (1 / volumeSlots))}
7071
case 6:
7172
if volume - (1 / volumeSlots) < 0.0 {MPVolumeView.setVolume(0.0)} else {MPVolumeView.setVolume(volume - (1 / volumeSlots))}
73+
case 224:
74+
updateMusicInformation(songInfo: getCurrentSongInfo())
7275
default:
7376
break
7477
}

0 commit comments

Comments
 (0)