Austin Berenyi
Austin Berenyi

Reputation: 1053

Can I filter out songs downloaded to device from Apple Music?

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?

Upvotes: 1

Views: 406

Answers (1)

Jelena
Jelena

Reputation: 11

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;

Upvotes: 1

Related Questions