MPMoviePlayerController breaks/stops after going to fullscreen in iOS6

后端 未结 11 1027
南方客
南方客 2020-12-24 07:10

I have a MPMoviewPlayerViewController embedded into an UIView object. When I start the player in the embedded mode everything works fine and as exp

11条回答
  •  [愿得一人]
    2020-12-24 07:23

    Just add shouldAutoplay boolean to YES after generating the URL It worked for me.

    like this:

    NSString *path = [[NSBundle mainBundle] pathForResource:videoFileName ofType:@"mp4" inDirectory:nil];
        NSURL *movieURL = [NSURL fileURLWithPath:path];
        MPMoviePlayerController *player = [[MPMoviePlayerController alloc] init]; 
    
        player.contentURL = movieURL;
        player.controlStyle = MPMovieControlStyleNone;    
    
        player.shouldAutoplay = YES;
        [player prepareToPlay];
        player.fullscreen = YES;
    
        [player.view setFrame:[[[[UIApplication sharedApplication] delegate] window] frame]];  // player's frame must match parent's
    
        [[[[UIApplication sharedApplication] delegate] window] addSubview: player.view];
    
        [player play];
    

提交回复
热议问题