MPMediaPickerController.showsCloudItems seems to do nothing

前端 未结 4 724
暖寄归人
暖寄归人 2021-02-07 11:54

Posted this on Apple with no luck, but now that the iOS 6 NDA is up, hoping more eyes will see it here.

I am attempting to modify an app to only allow a user to select

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-07 12:18

    I had this same problem. Although I was unable to hide the items, here's a good workaround that I used to prevent people from being able to select them. Inside didPickMediaItems, you should temporarily load it into an AVPlayerItem and then just check the validity of that item like so:

    - (void)mediaPicker:(MPMediaPickerController *)mediaPicker didPickMediaItems:(MPMediaItemCollection *)mediaItemCollection
    {
       MPMediaItem *selectedItem = [[mediaItemCollection items]objectAtIndex:0];
       NSURL *tempURL = [selectedItem valueForProperty:MPMediaItemPropertyAssetURL];
       AVPlayerItem *playerItem = [[AVPlayerItem alloc]initWithURL:tempURL];
    
       if(playerItem.loadedTimeRanges==NULL)
       {
         UIAlertView *alert=[[[UIAlertView alloc]initWithTitle:NSLocalizedString(@"Invalid Song Choice",NULL) message:NSLocalizedString(@"Please choose a song that is local to your phone.",NULL) delegate:self cancelButtonTitle:NSLocalizedString(@"Okay",NULL) otherButtonTitles:nil]autorelease];
         [alert show];
         [playerItem release];
       }
       else
       { 
           NSLog(@"Your good to go...do whatever you want with the local song");
       }
    }
    

提交回复
热议问题