Pages

Subscribe:

Wednesday, July 7, 2010

Playing video in iPhone

#import "PlayVideoViewController.h"
#import "MediaPlayer/MediaPlayer.h"

@implementation PlayVideoViewController



- (void)viewDidLoad
{

NSString *url = [[NSBundle mainBundle]
pathForResource:@"Miracle"
ofType:@"mp4"];

MPMoviePlayerController *player =
[[MPMoviePlayerController alloc]
initWithContentURL:[NSURL fileURLWithPath:url]];

[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(movieFinishedCallback:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:player];

//---play movie---
[player play];

// Changing the orientation
// [player setOrientation:UIDeviceOrientationPortrait animated:NO];
[super viewDidLoad];
}



- (void) movieFinishedCallback:(NSNotification*) aNotification {
MPMoviePlayerController *player = [aNotification object];
[[NSNotificationCenter defaultCenter]
removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:player];
[player autorelease];
}
@end

2 comments:

Unknown said...

You r good! !! !!! !!!!
(wahid here)

Erfan said...

Thankssss.......:)
but why this name...!!!???

Post a Comment