2012-09-16 166 views
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]; 

一切似乎右B'沒有加載視頻,我只看到一個黑屏。

  • 如何隱藏MPVideoPlayerView中的控件?

回答

0

代替 [NSURL URLWithString:moviePath]

使用

[NSURL fileURLWithString:moviePath] 

讓我這麼多次.. :)