Posts

Post not yet marked as solved
3 Replies
2.3k Views
I have a production app that I recently added support for playing Apple Music songs.The user can pick Apple Music songs via MPMediaPickerController, I save the persistentID and then use an MPMediaQuery to retrieve the MPMediaItem and play it with the MPMusicPlayerController.This logic works 95% of the time, but in the remaining opportunities, the MPMediaQuery returns no items matching the persistentID that was just provided by the MPMediaPickerController.I have not been able to duplicate the problem, but have implemented extensive error logging to debug the issue and made the following observiations.This only happens with Apple Music songs indicated by "hasProtectedAsset" flag set.The MPMediaItems do not have the "isCloudItem" set.This seems to happen with multiple songs from the same users.It has occured with devices from iPhone 6 up to iPhone XI have only observed this behavior on devices with iOS 11.2.6The users SKCloudServiceCapabilityMusicCatalogPlayback capability is verified.The persistentID that is returned with the MPMediaItem from the MPMediaPickerController is verified the same as the one used in the query.The query failure can occur within seconds of the MPMediaPickerController return so it is unlikely anything has happened to the device or music library.The query will fail again if retried.A subsequent MPMediaQuery using a predicate of the artist and track name will also fail.The user can go back into their library in the music app, remove and readd the item, it will get the same persistentID and the MPMediaQuery will no longer fail. Is this an indicator of some sort of corruption in the users media library?Is there anything I can do to detect this condition and/or advise the user how to resolve it?
Posted Last updated
.