Created
October 15, 2015 04:46
-
-
Save stan229/23cdbdb9777920a32786 to your computer and use it in GitHub Desktop.
Showing and Hiding MPMediaPlayerController instance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(void)showMediaPicker { | |
if(self.mediaPicker == nil) { | |
self.mediaPicker = [[MPMediaPickerController alloc] initWithMediaTypes:MPMediaTypeAnyAudio]; | |
[self.mediaPicker setDelegate:self]; | |
[self.mediaPicker setAllowsPickingMultipleItems:NO]; | |
[self.mediaPicker setShowsCloudItems:NO]; | |
self.mediaPicker.prompt = @"Select song"; | |
} | |
AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; | |
[delegate.rootViewController presentViewController:self.mediaPicker animated:YES completion:nil]; | |
} | |
void hideMediaPicker() { | |
AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; | |
[delegate.rootViewController dismissViewControllerAnimated:YES completion:nil]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment