1

MPMoviePlayer (フルスクリーンではない) からビデオを再生しています。フルスクリーンに入ると、ビデオが再生され続け、フルスクリーンが表示されます。しかし、もう一度全画面表示を閉じると、「小さい」ビデオが再生されていた場所に黒い背景しか表示されません。タッチしても何も反応しません。

プレーヤーで stop を呼び出すことはなく、viewdiddissapear (または同様の) 関数が宣言されていません。ムービープレーヤーもリリースされていません。

フルスクリーンを閉じてもビデオの再生を続けたい。何かご意見は?

**編集 iPad 1では動作しますが、iPad 2では動作しません...奇妙です...すべてで機能する必要があります。

ムービープレーヤーの初期化:

NSURL *fileURL = [NSURL fileURLWithPath:filePath];
self.moviePlayer = [[MPMoviePlayerController alloc] init];
self.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
self.moviePlayer.controlStyle = MPMovieControlStyleEmbedded;
self.moviePlayer.contentURL = fileURL;
self.moviePlayer.backgroundView.backgroundColor = [UIColor blackColor];
self.moviePlayer.shouldAutoplay = YES;
[self.moviePlayer.view setFrame:CGRectMake(1024, floorf((self.view.bounds.size.height / 2) - (318 / 2)), 425, 318)];
[self.moviePlayer prepareToPlay];


[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(MPMoviePlayerLoadStateDidChange:)
                                             name:MPMoviePlayerLoadStateDidChangeNotification
                                           object:self.moviePlayer];

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(MPMoviePlayerDidFinish:)
                                             name:MPMoviePlayerPlaybackStateDidChangeNotification
                                           object:self.moviePlayer];

[self.view addSubview:self.moviePlayer.view];
[self.view bringSubviewToFront:self.moviePlayer.view];

[UIView animateWithDuration:0.25
                      delay:0.0
                    options:UIViewAnimationCurveEaseOut
                 animations:^{
                     self.moviePlayer.view.transform = CGAffineTransformIdentity;
                     self.moviePlayer.view.position = CGPointMake(floorf(787 - (self.moviePlayer.view.frame.size.width / 2)),
                                                      self.moviePlayer.view.position.y);
                 }
                 completion:nil];

通知

- (void)MPMoviePlayerLoadStateDidChange:(NSNotification *)notification
{
NSLog(@"Loadstate changed");
if((self.moviePlayer.loadState & MPMovieLoadStatePlaythroughOK) == MPMovieLoadStatePlaythroughOK)
{
    [self.moviePlayer play];
}
}

- (void)MPMoviePlayerDidFinish:(NSNotification *)notification
{
MPMovieFinishReason finishReason = (MPMovieFinishReason) [notification.userInfo objectForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey];

switch(finishReason)
{
    case MPMovieFinishReasonPlaybackError: NSLog(@"Stopped playback due to error");
    case MPMovieFinishReasonPlaybackEnded: NSLog(@"I just quitted");
    case MPMovieFinishReasonUserExited: NSLog(@"User quitted");
}
}
4

0 に答える 0