【问题标题】:MPMoviePlayerController showing white background onlyMPMoviePlayerController 仅显示白色背景
【发布时间】:2013-10-09 16:19:11
【问题描述】:

在我的应用程序中,我想在 MPMoviePlayerController 中播放视频,但是当我运行该应用程序时,它只显示一个白框。这是代码:

NSBundle *bundle = [NSBundle mainBundle];
NSString *moviePath = [bundle pathForResource:@"Problems" ofType:@"MP4"];
NSLog(@"path: %@", moviePath);
//NSURL *movieURL = [NSURL fileURLWithPath:moviePath];
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:moviePath]];
player.view.frame = CGRectMake(0, 0, 700, 700);
player.view.backgroundColor = [UIColor whiteColor];
player.controlStyle = MPMovieControlStyleDefault;
player.shouldAutoplay = YES;
[self.detailView addSubview:player.view];
[player play];

编辑:我尝试了这段代码,并为 MPMoviePlayerController 添加了一个@property。我现在可以看到播放器,但应用程序崩溃并且断点无法确定在哪里。这是代码:

self.player = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"Problems" ofType:@"MP4"]]];
[self.player.view setFrame:CGRectMake(0, 0, 320, 320)];

[self.detailView addSubview:self.player.view];
[self.player play];

【问题讨论】:

    标签: ios avfoundation mpmovieplayercontroller


    【解决方案1】:

    你应该使用方法'presentMoviePlayerViewControllerAnimated:':

    [self presentMoviePlayerViewControllerAnimated:self.player];
    

    【讨论】:

      猜你喜欢
      • 2010-12-02
      • 1970-01-01
      • 1970-01-01
      • 2013-11-27
      • 2015-08-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多