Hi to all, i am creating a movie application in iphone . i want to play a video in my application. My Video url is located locally. Please anybody help me in how can i play a video in my application
A:
Where is it located locally? In the application bundle? If so, the URL is like this:
NSURL *url = [NSURL URLWithString:[[NSBundle mainBundle] pathForResource:@"videoname" ofType:@"mov" inDirectory:@""]];
You can play most videos with Apple's MediaPlayer-framework.
Add the framework (MediaPlayer) to your project and import it in the .h
-file, and create an instance of the MediaPlayer like this:
// .h:
#import <MediaPlayer/MediaPlayer.h>
// .m:
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];
[[player view] setFrame:[self.view bounds]]; // Frame must match parent view
[self.view addSubview:[player view]];
[player play];
[player release];
Emil
2010-09-25 09:44:38