MPMusicPlayerController `append` and `prepend` don't work with MPMusicPlayerMediaItemQueueDescriptor constructed with MPMediaItemCollection

Originator:rob
Number:rdar://30298287 Date Originated:January 31, 2017
Status:Open Resolved:
Product:iOS + SDK Product Version:iOS 10.3 beta 1
Classification: Reproducible:Always
 
Area:
Media Player Framework

Summary:
MPMusicPlayerController `append` and `prepend` don't work with MPMusicPlayerMediaItemQueueDescriptor constructed with MPMediaItemCollection.

Using a MPMusicPlayerMediaItemQueueDescriptor constructed with a MPMediaQuery appears to work as expected

Steps to Reproduce:
1. Invoke this code on a device that has at least 1 song in it’s media library.

let song = MPMediaQuery.songs().items?.first!
let collection = MPMediaItemCollection(items: [song])
let descriptor = MPMusicPlayerMediaItemQueueDescriptor(itemCollection: collection)
MPMusicPlayerController.applicationQueuePlayer().append(descriptor)
MPMusicPlayerController.applicationQueuePlayer().play()

Expected Results:
The first song should play.

Actual Results:
No music plays.

Version:
iOS 10.3 beta 1 (14E5230e)

Notes:
Constructing a descriptor from a MPMediaQuery seems to work as expected.

let song = MPMediaQuery.songs().items?.first!
let predicate = MPMediaPropertyPredicate(value: song.persistentID, forProperty: MPMediaItemPropertyPersistentID)
let query = MPMediaQuery(filterPredicates: [predicate])
let descriptor = MPMusicPlayerMediaItemQueueDescriptor(query: query)
MPMusicPlayerController.applicationQueuePlayer().append(descriptor)
MPMusicPlayerController.applicationQueuePlayer().play()

Comments

MPMusicPlayerMediaItemQueueDescriptor(itemCollection:) broken in general

Actually the problem turns out to run even deeper than you suggest here. I have file a bug report radar 35057087 showing that MPMusicPlayerMediaItemQueueDescriptor(itemCollection:) always fails, even for basic things like setting the queue. If, instead of play, you call prepareToPlay with the completion handler, which provides an error parameter, you can see there's a completely spurious error every time claiming that the storefront is wrong, as if we were using a totally different queue descriptor having to do with Apple Music.


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!