How to play Apple Music files (even "available offline") using AVPlayer?

Is it possible to play Apple Music files - even the "available offline" ones - using AVPlayer? I tried the following code to get 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]; ... 

Thank you for reading.

EDIT: Discussions on the Apple Developers Forum suggest that this might not be possible if AVPlayer is not used. But then it prevents sound processing, so this is not an option, unfortunately.

+5
source share
1 answer

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

0
source

Source: https://habr.com/ru/post/1232520/


All Articles