嗨,我已经为ipad创建了应用程序,它在资源文件夹中有一个视频文件,当用户点击播放按钮时,它就会播放。它在用户第一次点击播放按钮时起作用,但当用户随后播放视频时,会出现file.The问题,即视频不播放,只有音频是playing.These问题,不是随机发生的,而是以后会发生的。
当我点击播放器右下角的双箭头图标时,当我单击播放器右下角的双箭头图标时,电影将进入全屏,并在视频正在播放的时间显示视频.At。
有人能帮我吗?
下面是我的示例代码
MPMoviePlayerController *moviePlayer;} @property (读写,保留) MPMoviePlayerController *moviePlayer;@合成moviePlayer;
- (void)viewDidLoad {
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(movieFinishedCallback:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:self.moviePlayer];
[super viewDidLoad];
}
-(IBAction)PlayBtnPressed:(id)sender
{
NSURL *movieURL;
NSString *moviePath = [[NSBundle mainBundle] pathForResource:@"title" ofType:@"mp4"];
movieURL = [NSURL fileURLWithPath:moviePath];
// Initialize a movie player object with the specified URL
MPMoviePlayerController *mp = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
if (mp)
{
// save the movie player object
self.moviePlayer = mp;
[mp release];
UIInterfaceOrientation orientation = [[UIDevice currentDevice]orientation];
[self shouldAutorotateToInterfaceOrientation:orientation];
// Play the movie!
[self.view addSubview:self.moviePlayer.view];
[self.moviePlayer play];
}
}
- (void) movieFinishedCallback:(NSNotification*) aNotification {
NSLog(@"movieFinishedCallback aNotification");
MPMoviePlayerController *player = [aNotification object];
[[NSNotificationCenter defaultCenter]
removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:player];
[player stop];
[player.view removeFromSuperview];
}提前感谢......
发布于 2010-07-01 15:49:29
看起来movieplayer不会被释放,直到你在同一个电影文件上分配了第二个:
self.moviePlayer = mp;保留它,但电影完成的部分不做
self.moviePlayer = nil;可能是它给你带来了麻烦。
https://stackoverflow.com/questions/3155611
复制相似问题