我正在尝试从我的资源文件加载一个 25 秒的 mp4 电影,但是当我播放它时,我的 MPMoviePlayerPlaybackDidFinishNotification 选择器会立即使用 MPMovieFinishReasonPlaybackEnded 调用。当我记录我的播放状态时,它会显示:
MPMoviePlaybackStatePlaying
MPMoviePlaybackStatePaused
MPMoviePlaybackStateStopped
MovieFinishReasonPlaybackEnded
MPMoviePlaybackStatePlaying
MPMoviePlaybackStatePaused
即使我只调用一次 play 方法。我希望有一个人可以帮助我。
-- 编辑显示我的代码:
MPMoviePlayerController* player = [[[MPMoviePlayerController alloc] initWithContentURL:movieURL] autorelease];
if (player)
{
self.moviePlayerController = player;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:player];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayerPlaybackStateDidChange:)
name:MPMoviePlayerPlaybackStateDidChangeNotification
object:player];
player.contentURL = movieURL;
player.movieSourceType = MPMovieSourceTypeFile;
player.controlStyle = MPMovieControlStyleNone;
player.fullscreen = YES;
switch (orientation) {
case UIInterfaceOrientationLandscapeLeft:
player.view.transform = CGAffineTransformMakeRotation(90.0f * (M_PI / 180.0f));
break;
case UIInterfaceOrientationLandscapeRight:
player.view.transform = CGAffineTransformMakeRotation(-90.0f * (M_PI / 180.0f));
break;
default:
break;
}
player.view.frame = self.view.bounds;
[self.view addSubview:player.view];
}
[self.moviePlayerController play]