1

I'm using MPMediaPickerController to select songs from user's music library. Those songs that will be selected by user will be played using AVAudioPlayer.

My app was already live on the app Store, but I've received some reports from users that there were bugs on my app. They can't add song from their library.

Here is my code in presenting the MPMediaPickerController:

  MPMediaPickerController *picker = [[MPMediaPickerController alloc] initWithMediaTypes:  MPMediaTypeMusic];

  picker.delegate = self;
  picker.allowsPickingMultipleItems = YES;
  picker.showsCloudItems = NO;
  [picker setPreferredContentSize: CGSizeMake( 320, 440)];
  [self.navigationController presentViewController: picker animated: YES completion: nil];

Here is my code on getting the songs that was selected by users.

- (void) mediaPicker: (MPMediaPickerController *) mediaPicker didPickMediaItems: (MPMediaItemCollection *) mediaItemCollection 
{
    BOOL protectedDRMFileFound = NO;

   NSMutableArray *array = [[NSMutableArray alloc]init];

   for (MPMediaItem *mediaItem in [mediaItemCollection items])
   {

    if ([[mediaItem valueForProperty: MPMediaItemPropertyAssetURL]relativeString] != nil)
    //Note: DRM Protected file does not shows Asset URL so usually it is nil , if not nil it is not DRM Protected
       {
          [array addObject: mediaItem];
       }
       else
       {
         protectedDRMFileFound = YES;
       }   
  }

  if (protectedDRMFileFound)
    {
      UIAlertView *alert = [[UIAlertView alloc]initWithTitle: @""
                                                     message: @"One or more track cannot be played because it is DRM-protected or otherwise not available."
                                                    delegate: nil 
                                           cancelButtonTitle: @"OK" 
                                           otherButtonTitles: nil];

     [alert show];
   }


  userMediaCollection = array;
 } 

Some users reports that their songs were not DRM-protected and they can't select any song from MPMediaPickerController. I've asked them for a copy of song which they can not use on my app for testing. On my tests, I have not yet experience what they had experienced on adding the songs to my app. I'm stuck on thinking of what would might be the problem on my app. Does anyone experience something similar to this problem.

edie
  • 758
  • 1
  • 11
  • 29

0 Answers0