How to play Apple Music files (even "available offline" ones) with AVPlayer?
Asked Answered
S

1

8

Is it possible to play Apple Music files—even the "available offline" ones—with AVPlayer? I've tried the following code to retrieve the URL, but it returns nil:

- (void)mediaPicker:(MPMediaPickerController *)mediaPicker didPickMediaItems:(MPMediaItemCollection *)mediaItemCollection{
    [mediaPicker dismissViewControllerAnimated:YES completion:nil];

    NSURL *thisURL=[[[mediaItemCollection items] firstObject] valueForProperty:MPMediaItemPropertyAssetURL];
...

Thanks for reading.

EDIT: Discussions on the Apple Developer forum suggest this may not be possible, unless AVPlayer is not used. But then that prevents audio processing, so not an option unfortunately.

Sherry answered 29/9, 2015 at 9:33 Comment(0)
S
1

Apple Music assets are DRM protected, as expected. Additionally, offline songs do not have a valid Asset URL you can use with AVPlayer. The only way to play Apple Music songs is by using MusicKit with MPMusicPlayerController, or Apple Music API available in iOS 11.

Sainthood answered 22/6, 2017 at 6:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.