0
`我面臨問題,以開發在ios5 Xcode編程中運行mp4視頻的代碼。 當我運行的應用程序關注的是,雖然顯示文件clip2.mp4在我bundle.please給我一個 妥善解決視頻播放器不工作在Xcode 4.2
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSString *url = [[NSBundle mainBundle]
pathForResource:@"clip2"
ofType:@"mp4"];
player =[[MPMoviePlayerController alloc]
initWithContentURL:[NSURL fileURLWithPath:url]];
[player prepareToPlay];
[player play];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(movieFinishedCallback:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:player];
//---play movie---
}
- (void) movieFinishedCallback:(NSNotification*) aNotification {
MPMoviePlayerController *play= [aNotification object];
[[NSNotificationCenter defaultCenter]
removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:play];
//[player autorelease];
} `