Reputation: 1171
I have a video saved in my xcode project that I want to play as a response to a button click. Does IOS have built in media API's to handle that? Could anyone give the class name that handles video on the iPhone?
Upvotes: 1
Views: 277
Reputation: 2177
Here's some code to get you started:
MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"yourfilename" ofType:@"m4v"]]];
[[moviePlayerController view] setFrame:CGRectMake(0, 0, parentView.frame.size.width, parentView.frame.size.height)];
[moviePlayerController setShouldAutoplay:NO];
[moviePlayerController setControlStyle:MPMovieControlStyleEmbedded];
[[moviePlayerController backgroundView] setBackgroundColor:[UIColor clearColor]];
[moviePlayerController prepareToPlay];
By the documentation you have to set the MPMoviePlayerController's frame with a frame as big as the parent view's.
Upvotes: 1
Reputation: 12106
MPMoviePlayerViewController. Please search a little bit before asking questions.
Upvotes: 1