ARCを使用しているという既知の問題があります.hにプレーヤーを追加する必要があります。これは、ローカルで宣言した場合でも解放されるためです。
@property (nonatomic, strong) MPMoviePlayerController* controller;
ビューを追加するには:
self.controller = [[MPMoviePlayerController alloc] initWithContentURL:YOURVIDEOURL];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:self.controller];
self.controller.controlStyle = MPMovieControlStyleDefault;
self.controller.shouldAutoplay = YES;
[self.view addSubview:self.controller.view];
[self.controller setFullscreen:YES animated:YES];
そして、ビューを削除するには:
- (void) moviePlayBackDidFinish:(NSNotification*)notification {
if (UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation))
{
[[UIApplication sharedApplication] setStatusBarOrientation:UIDeviceOrientationPortrait animated:NO];
}
MPMoviePlayerController *player = [notification object];
[[NSNotificationCenter defaultCenter]
removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:player];
if ([player
respondsToSelector:@selector(setFullscreen:animated:)])
{
[player.view removeFromSuperview];
}
}