MPMoviePlayerController不';带iOS 5的iPad1上的t环
我有一部短片,在我的视角背景下循环播放。我使用MPMoviePlayerController播放电影。repeatMode设置为MPMovierPeatModeOne,在iPad2、3和模拟器上都可以正常工作。然而,在iPad1上,电影循环一次,在第二次播放后立即停止。该项目为iOS 5 w/o ARC(从GM测试到5.1.1)MPMoviePlayerController不';带iOS 5的iPad1上的t环,ipad,ios5,mpmovieplayercontroller,Ipad,Ios5,Mpmovieplayercontroller,我有一部短片,在我的视角背景下循环播放。我使用MPMoviePlayerController播放电影。repeatMode设置为MPMovierPeatModeOne,在iPad2、3和模拟器上都可以正常工作。然而,在iPad1上,电影循环一次,在第二次播放后立即停止。该项目为iOS 5 w/o ARC(从GM测试到5.1.1) 如何让电影在iPad 1上循环播放?经过多次尝试,我终于找到了解决这个问题的方法: 在注册更改播放状态通知MPMoviePlayerPlayerBackstateDid
如何让电影在iPad 1上循环播放?经过多次尝试,我终于找到了解决这个问题的方法: 在注册更改播放状态通知MPMoviePlayerPlayerBackstateDidChangeNotification后,电影会无休止地循环,在iPad 1上进行第二次播放后不会停止。请记住,这种行为并没有发生在iPad2、3或模拟器上 为通知执行的选择器不能为空。只需要分配一个布尔值之类的。上面的扩展代码是:
- (void)loadVideo {
// Create the controller
NSString *urlStr = [[NSBundle mainBundle] pathForResource:@"movieFileName.m4v" ofType:nil];
NSURL *url = [NSURL fileURLWithPath:urlStr];
self.videoPlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
// Configure the controller
self.videoPlayer.controlStyle = MPMovieControlStyleNone;
self.videoPlayer.scalingMode = MPMovieScalingModeFill;
self.videoPlayer.repeatMode = MPMovieRepeatModeOne;
self.videoPlayer.view.userInteractionEnabled = NO;
[self.videoPlayer.view setFrame:self.movieContainer.bounds];
// Register for notifications
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerNotification:) name:MPMoviePlayerPlaybackStateDidChangeNotification object:videoPlayer];
self.listeningToMoviePlayerNotifications = YES;
// Add its view to the hierarchy
[self.movieContainer addSubview:self.videoPlayer.view];
}
- (void)moviePlayerNotification:(NSDictionary *)userInfo {
// Do anything here, for example re-assign the listeningToMoviePlayerNotification-BOOL
self.listeningToMoviePlayerNotifications = YES;
}
经过多次尝试,我终于找到了解决这个问题的方法: 在注册更改播放状态通知MPMoviePlayerPlayerBackstateDidChangeNotification后,电影会无休止地循环,在iPad 1上进行第二次播放后不会停止。请记住,这种行为并没有发生在iPad2、3或模拟器上 为通知执行的选择器不能为空。只需要分配一个布尔值之类的。上面的扩展代码是:
- (void)loadVideo {
// Create the controller
NSString *urlStr = [[NSBundle mainBundle] pathForResource:@"movieFileName.m4v" ofType:nil];
NSURL *url = [NSURL fileURLWithPath:urlStr];
self.videoPlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
// Configure the controller
self.videoPlayer.controlStyle = MPMovieControlStyleNone;
self.videoPlayer.scalingMode = MPMovieScalingModeFill;
self.videoPlayer.repeatMode = MPMovieRepeatModeOne;
self.videoPlayer.view.userInteractionEnabled = NO;
[self.videoPlayer.view setFrame:self.movieContainer.bounds];
// Register for notifications
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerNotification:) name:MPMoviePlayerPlaybackStateDidChangeNotification object:videoPlayer];
self.listeningToMoviePlayerNotifications = YES;
// Add its view to the hierarchy
[self.movieContainer addSubview:self.videoPlayer.view];
}
- (void)moviePlayerNotification:(NSDictionary *)userInfo {
// Do anything here, for example re-assign the listeningToMoviePlayerNotification-BOOL
self.listeningToMoviePlayerNotifications = YES;
}
我已经有了答案,但我必须等8个小时才能回答我自己的问题,因为我只有不到10个左右的答案。请耐心点。答案的实质是:你必须听MPMoviePlayerPlayerBackstateDidChangeNotification。我已经有了答案,但我必须等8个小时才能回答我自己的问题,因为我只有不到10个问题。请耐心点。答案的实质是:你必须听MPMoviePlayerPlayerBackstateDidChangeNotification。