MPMusicPlayerController.systemMusicPlayer.nowPlayingItem
is not change state only after Music App killed and reopen.
Specifically,
- Open Music App and play music.
- Open created app by me. It's using
MPMusicPlayerController.systemMusicPlayer.nowPlayingItem
. ConfirmnowPlayingItem
data is correct(included current playing music data). - Switch to Music App and kill. Then, reopen Music App and change music.
- 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.