1

I have a MPMediaPickerController showing songs available on the device to use for sending to other users on my app. I've filtered out Cloud items, but I also want to filter out songs from Apple Music that have been made "available offline."

-(void)openMusic:(NSNotification *)notification {

    if ([[notification name] isEqualToString:@"myMusic"]){

        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.75 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
            MPMediaPickerController *mediaPicker = [[MPMediaPickerController alloc] initWithMediaTypes:MPMediaTypeMusic];
            mediaPicker.delegate = self;
            mediaPicker.allowsPickingMultipleItems = NO;
            mediaPicker.showsCloudItems = NO;
            [self presentViewController:mediaPicker animated:YES completion:nil];
        });

    }


}

Currently, it's still showing all downloaded Apple Music tracks. How can I filter them out?

Austin Berenyi
  • 1,013
  • 2
  • 13
  • 25
  • I still don't know how to hide Apple Music items that have been made available offline, but I did discover that when an Apple Music item has been downloaded to the device the track's `itemURL = nil` so perhaps that can be used to filter them out of `MPMediaPickerController` – Austin Berenyi Dec 13 '17 at 03:14

1 Answers1

1

According to this answer, if you use:

picker.showsCloudItems = NO;

You will get the list of songs that either were manually downloaded in the Music app or songs that were streamed and therefore cached. However, since Apple Music songs are DRM protected, to display only songs downloaded locally, you need to add this line, too:

picker.showsItemsWithProtectedAssets = NO;

Jelena
  • 11
  • 4