iOS: How to use MPMoviePlayerController

后端 未结 4 1906
刺人心
刺人心 2020-12-08 00:54

I\'ve created a blank project (iOS) and put this in my viewDidLoad:

NSString *moviePath = [[NSBundle mainBundle] pathForResource:@\"Movie\" ofType:@\"m4v\"];         


        
4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-08 01:24

    You have to try this......

    NSString *path = [[NSBundle mainBundle]pathForResource:@"test" ofType:@"mp4"];
        player = [[MPMoviePlayerViewController alloc]initWithContentURL:[NSURL fileURLWithPath:path]];
        [player.view setFrame:CGRectMake(0, 0, 320, 320)];
        [self presentMoviePlayerViewControllerAnimated:player];
        [player.moviePlayer play];
         [self.view addSubview:player.view];
    

提交回复
热议问题