0

我正在创建一个 iPad 应用程序,我想在应用程序加载数据时在启动屏幕上无控制地播放视频全屏,我搜索并找到了一些关于 MPPlayerViewController 的文章,我使用它但我有一些问题如下:

  • 我使用以下代码播放视频:
NSString *moviePath = [ [[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"StartupVideo.mp4"];
    moviePlayerViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:moviePath]];
    moviePlayerViewController.view.frame = self.view.bounds;

    [self.view addSubview:moviePlayerViewController.view];
    [self.view sendSubviewToBack:moviePlayerViewController.view];

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieFinishedCallback:)
                                                 name:MPMoviePlayerPlaybackDidFinishNotification
                                               object:[moviePlayerViewController moviePlayer]];

    MPMoviePlayerController *player = [moviePlayerViewController moviePlayer];
    player.fullscreen = YES;
    player.movieSourceType = MPMovieSourceTypeFile;
    player.initialPlaybackTime = -1.0;
    [player play];

一切似乎都正确,但视频未加载,我只看到黑屏。

  • 如何隐藏 MPVideoPlayerView 中的控件?
4

1 回答 1

0

代替 [NSURL URLWithString:moviePath]

利用

[NSURL fileURLWithString:moviePath]

让我这么多次.. :)

于 2013-06-06T21:22:09.147 回答