MPMediaItem playback duration is zero for any iTunes Music track

I'm using MPMediaPickerController in my app to select an Apple Music track. In the mediaPicker:didPickMediaItems I get track duration from the MPMediaItemPropertyPlaybackDuration property but it's always zero in iOS 13 beta 6.


This issue just started appearing in beta 6. My apps rely on this duration being accurate and it was correct in the earlier iOS 13 betas.


- (void)mediaPicker: (MPMediaPickerController *)mediaPicker didPickMediaItems:(MPMediaItemCollection *)mediaItemCollection {


if (mediaItemCollection) {

for (MPMediaItem *chosenMediaItem in mediaItemCollection.items) {


NSNumber *mediaTrackDurationNumber = [chosenMediaItem valueForProperty:MPMediaItemPropertyPlaybackDuration];


// MPMediaItemPropertyPlaybackDuration is a

NSTimeInterval so storing as a double

double duration = [mediaTrackDurationNumber doubleValue];


NSLog(@"media item duration = %f", duration); // Always prints 0

}

}

}


.. Code is from a sample app attached to FB 6963688 and submitted through Feedback Assistant.


Is there another way to retrieve the MPMediaItem duration?

Replies

Yep, and mediaType is still 0 for every media item in beta 8, so my app doesn't allow me to select anything since they're not marked as MediaTypeMusic. I imagine playbackDuration is also still 0 in beta 8.