1

MPMusicPlayerController.systemMusicPlayer.nowPlayingItem is not change state only after Music App killed and reopen. Specifically,

  1. Open Music App and play music.
  2. Open created app by me. It's using MPMusicPlayerController.systemMusicPlayer.nowPlayingItem. Confirm nowPlayingItem data is correct(included current playing music data).
  3. Switch to Music App and kill. Then, reopen Music App and change music.
  4. Switch to my app and show nowPlayingItem data. I want current music data, but it's old Music data.
// Run SceneDelegate when foreground that my app.
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
...
    func sceneWillEnterForeground(_ scene: UIScene) {
        // Called as the scene transitions from the background to the foreground.
        // Use this method to undo the changes made on entering the background.
        player = MPMusicPlayerController.systemMusicPlayer
        print(player?.nowPlayingItem?.title)

That's code correct ran at iOS13.3. After update to iOS13.4, not correct running.

peropero
  • 11
  • 1
  • This issue is still happen on iOS13.4.1. – peropero Apr 09 '20 at 06:58
  • I experience the same issue. My app plays a new item via `systemMusicPlayer.play()` and when I check `systemMusicPlayer.nowPlayingItem` shortly after (I subscribed to `MPMusicPlayerControllerPlaybackStateDidChangeNotification`) it's still the item from before. – mrtnlst Jun 07 '20 at 14:47
  • Me too. Still happening on iOS 14.0.1 – Ryohei Oct 09 '20 at 07:30
  • By the way, after some experiments I found out if you use `applicationMusicPlayer` instead of `systemMusicPlayer`, `nowPlayItem` became nil. You could possibly switch to `applicationMusicPlayer` – Ryohei Oct 13 '20 at 07:29

0 Answers0