我正在创建一个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];
一切似乎都没错,但视频没有加载,我只看到黑屏。
答案 0 :(得分:0)
[NSURL URLWithString:moviePath]
使用
[NSURL fileURLWithString:moviePath]
让我这么多次.. :)