视频剪辑无法正常播放

时间:2011-02-12 17:40:12

标签: iphone xcode video sdk

我正在尝试在我的某个屏幕上播放视频。它似乎运行但是当文件打开时,全屏加载并立即关闭。该视频只有几秒钟,并且是m4v格式。我添加了框架并导入了类。如何才能使视频正常播放?

我的标题:

-(IBAction)playMedia:(id)sender {

NSString *movieFile;
MPMoviePlayerController *moviePlayer;

movieFile = [[NSBundle mainBundle]
             pathForResource:@"movie" ofType:@"m4v"];
moviePlayer = [[MPMoviePlayerController alloc]
               initWithContentURL: [NSURL fileURLWithPath: movieFile]];

[moviePlayer.view setFrame:CGRectMake(145.0, 20.0, 155.0 , 100.0)];
[self.view addSubview:moviePlayer.view ];

[[NSNotificationCenter defaultCenter] addObserver:self
                                selector:@selector(playMediaFinished:)
                                name:MPMoviePlayerPlaybackDidFinishNotification
                                object:moviePlayer];
[moviePlayer play];

if ([toggleFullscreen isOn]) {
    [moviePlayer setFullscreen:YES animated:YES];
}
}

我的实施文件是:

-(void)playMediaFinished: (NSNotification*)theNotfication {

MPMoviePlayerController *moviePlayer=[theNotfication object];

[[NSNotificationCenter defaultCenter] removeObserver:self
                            name:MPMoviePlayerPlaybackDidFinishNotification
                            object:moviePlayer];

[moviePlayer.view removeFromSuperview];
[moviePlayer release];

}

感谢

0 个答案:

没有答案