Skip to content

Instantly share code, notes, and snippets.

@iPhoneNoobDeveloper
Last active August 29, 2015 14:13
Show Gist options
  • Save iPhoneNoobDeveloper/8b611066a01ee30690c6 to your computer and use it in GitHub Desktop.
Save iPhoneNoobDeveloper/8b611066a01ee30690c6 to your computer and use it in GitHub Desktop.
NSURL *url=[[NSURL alloc] initWithString:adVideoObj.url];
MPMoviePlayerController *moviePlayer=[[MPMoviePlayerController alloc] initWithContentURL:url];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayer];
// moviePlayer.movieSourceType = MPMovieSourceTypeStreaming;
moviePlayer.controlStyle=MPMovieControlStyleDefault;
[moviePlayer prepareToPlay];
//moviePlayer.shouldAutoplay=YES;
[self.view addSubview:moviePlayer.view];
[moviePlayer setFullscreen:YES animated:YES];
- (void) moviePlayBackDidFinish:(NSNotification*)notification
{
MPMoviePlayerController *player = [notification object];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification object:player];
if ([player respondsToSelector:@selector(setFullscreen:animated:)])
{
[player.view removeFromSuperview];
}
}
@iPhoneNoobDeveloper
Copy link
Author

Change the parameter as per your requirement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment