0

MPMoviePlayerController完了ボタンを押すのではなく、再生中にプログラムで終了する必要があります。出来ますか。完了ボタンのクリックをシミュレートする方法はありますか?

4

1 に答える 1

4

私はあなたのための 1 つのトリックがあります。uiview で mpmovieplayer を取得し、プレーヤーを停止した後に uiview を削除できます

ViewController.h 内

      MPMoviePlayerController *moviePlayerController;
      UIView *view1;
    -(IBAction)cancelPlay:(id)sender;

ViewController.m 内

  - (void)viewDidLoad
    {
        [super viewDidLoad];
        NSString *filepath = [[NSBundle mainBundle] pathForResource:@"try" ofType:@"mp4"];
        NSURL *fileURL = [NSURL fileURLWithPath:filepath];
        view1=[[UIView alloc]initWithFrame:CGRectMake(0, 10, 320, 300)];
        view1.backgroundColor=[UIColor blueColor];
        [self.view addSubview:view1];
        moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
        [moviePlayerController.view setFrame:CGRectMake(0, 10, 320,300)];
        [view1 addSubview:moviePlayerController.view];
        moviePlayerController.fullscreen = YES;
        moviePlayerController.controlStyle=MPMovieControlStyleEmbedded;
        [moviePlayerController play];
    }
    -(IBAction)cancelPlay:(id)sender{
        [moviePlayerController stop];
        [view1 removeFromSuperview];
    }
于 2013-06-17T10:46:48.903 に答える