Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to play video locally in objective-c for iphone?

I want to play the video on iphone locally by storing the video in the app. how can i do?

like image 695
uttam Avatar asked Feb 24 '10 07:02

uttam


2 Answers

NSString *path = [[NSBundle mainBundle] pathForResource:@"myVideo" ofType:@"mp4"];   

MPMoviePlayerController *myPlayer = [[MPMoviePlayerController alloc] init];
myPlayer.shouldAutoplay = YES;
myPlayer.repeatMode = MPMovieRepeatModeOne;
myPlayer.fullscreen = YES;
myPlayer.movieSourceType = MPMovieSourceTypeFile;
myPlayer.scalingMode = MPMovieScalingModeAspectFit;
myPlayer.contentURL =[NSURL fileURLWithPath:path];
[self.view addSubview:myPlayer.view];
[myPlayer play];
like image 143
Kemo Avatar answered Sep 24 '22 18:09

Kemo


To store video in the app, you can just add it with a copy files phase in the build. For an example of how to play a movie, check out the Media Player docs and especially the MoviePlayer sample code.

like image 40
Chuck Avatar answered Sep 22 '22 18:09

Chuck