Unable to play MP4 video file from mainBundle

前端 未结 7 596
挽巷
挽巷 2020-12-15 05:13

So I\'m trying to play a simple intro animation video file that I\'ve dragged into my project in XCode and therefore should be able to play from my mainBundle, right?

<
7条回答
  •  盖世英雄少女心
    2020-12-15 05:26

    NSURL *url = [NSURL URLWithString:[[NSBundle mainBundle] pathForResource:@"video" ofType:@"mov" inDirectory:@""]];
    
    MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:url];
    [[player view] setFrame:[self.view bounds]]; // Frame must match parent view
    [self.view addSubview:[player view]];
    [player play];
    [player release];
    

提交回复
热议问题