MPMoviePlayerViewController problem after movie ending

In iOS4 for iPhone 4 / 3GS, I have a tabular view and one of the cells plays the movie file. If the movie ends and the controls disappear, the view returns in the status bar. Like in this image ... that I'm too new to publishing. Look here ...

http://www.dezignwright.com/ios4_movie.png

If the controls are turned on when the movie ends, then there is no problem.

BONUS: How to make a movie play on an album when it starts playing. I do not want him to play in the portrait at all.

Thank.

+3
source share
5 answers

@Nuoji . iOS, MPMoviePlayerViewController . - iOS, ( ), , , .

1. , , MPMoviePlayerViewController.

2. DidFinishNotification

[[NSNotificationCenter defaultCenter] addObserver:self 
                                  selector:@selector(playbackDidFinish:)
                                      name:MPMoviePlayerPlaybackDidFinishNotification 
                                   object:nil];

3. reset , , . , .

[self performSelector:@selector(resetFrame)
           withObject:nil 
           afterDelay:kResetFrameDelay];

- (void)resetFrame {
    self.view.frame = kApplicationFrame;
}
+1

iOS 4.3.

.

+1

, , 4.0, "".

, , - , MPMoviePlayerPlaybackDidFinishNotification.

, , MPMoviePlayerViewController, shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation

.. - :

@interface CustomMoviePlayerViewController : MPMoviePlayerViewController
@end
@implementation CustomMoviePlayerViewController
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
    return toInterfaceOrientation == UIInterfaceOrientationLandscapeRight || toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft;
}
@end

, :

- (void)playbackEnded:(NSNotification *)notification
{
    [[self view] setFrame:[self originalFrame]];
}

- (void)playMovie:(NSString *)movieURLString
{
    MPMoviePlayerViewController *controller = [[CustomMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:movieURLString]];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playbackEnded:) name:MPMoviePlayerPlaybackDidFinishNotification object:[controller moviePlayer]];
    [self presentMoviePlayerViewControllerAnimated:controller];
}
0

, , , :

-(IBAction)playMovieButtonPressed:(id)sender { 
    MPMoviePlayerViewController* playerViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:[self localMovieURL]];
    [[NSNotificationCenter defaultCenter] addObserver:self 
            selector:@selector(playbackDidFinish:) 
             name:MPMoviePlayerPlaybackDidFinishNotification 
              object:playerViewController.moviePlayer];

 [self setWantsFullScreenLayout:NO]; 
 // this ensures that the original frame is restored correctly 
 // if the movie ends and the player is closed automatically

 [self presentMoviePlayerViewControllerAnimated:playerViewController];
    [playerViewController release];
    MPMoviePlayerController *player = [playerViewController moviePlayer];
    [player play];
}
0

, workaroud, :

-(void)myMovieFinishedCallback:(NSNotification*)aNotification
{
    if (self.interfaceOrientation == UIInterfaceOrientationPortrait || self.interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
        CGRect frame = CGRectMake(0, 20, 768, 1004);
        self.view.frame = frame;
    }else {
        CGRect frame = CGRectMake(0, 20, 1004, 768);
        self.view.frame = frame;
    }
}

Rect , iPad.

0

Source: https://habr.com/ru/post/1756014/


All Articles