Tôi gặp sự cố với MPMoviePlayerViewController, khi ứng dụng nhập vào nền và sau đó tôi khởi chạy lại hoặc chuyển sang chế độ xem khácCác bộ phim trở thành màu đen! Tôi có phim đóng trong nền của menu của tôi, đây là mã của tôi:MPMoviePlayerViewController trở thành màu đen khi nhập vào nền
EIDTED Mã sản phẩm:
-(void)viewDidLoad {
[self moviePlayer2];
}
- (void) moviePlayer2 {
NSString *path = [[NSBundle mainBundle] pathForResource:@"cloud" ofType:@"mp4"];
player = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL fileURLWithPath:path]];
player.view.userInteractionEnabled = YES;
player.moviePlayer.repeatMode = YES;
player.moviePlayer.scalingMode = MPMovieScalingModeFill;
player.moviePlayer.controlStyle = MPMovieControlStyleNone;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackStateChange:)
name:MPMoviePlayerPlaybackStateDidChangeNotification
object:[player moviePlayer]];
[[player moviePlayer] play];
[self.view addSubview:player.view];
}
-(void) moviePlayBackStateChange: (NSNotification *) note {
[[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackStateDidChangeNotification object:[player moviePlayer]];
[[player moviePlayer] play];
//[player release];
NSLog(@"FINISHED");
}
cảm ơn bạn.
hiện 'movieFinishedPlaying' được gọi khi ứng dụng của bạn chạy vào nền? Nếu bạn không biết, hãy đặt một điểm ngắt (hoặc sử dụng NSLog cho bảng điều khiển) và tìm hiểu. –
khi tôi chuyển đổi giữa các viewControllers có. trình biên dịch cho tôi thấy thông điệp NSLog –