2010-07-19 58 views
0

現在我想知道關於MPMoviePlaybackController的3.X和4之間的區別以及需要設置視圖並使其在子視圖控制器中充分工作的需要。但是,儘管下面的代碼看起來是正確的(對我來說),但我仍然只是在電影期間得到一個空白屏幕。我知道它作爲moviePlayBackDidFinish成功播放。如何在iOS4上顯示來自AppDelegate的視頻

我現在需要將它添加到模態或類似的位置嗎?

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {  

    MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:filePath]]; 

    player.fullscreen = YES; 
    player.controlStyle = MPMovieControlStyleNone; 
    [[player view] setFrame:window.bounds]; 
    [window addSubview: [player view]]; 

    [[NSNotificationCenter defaultCenter] addObserver:self 
       selector:@selector(moviePlayBackDidFinish:) 
       name:MPMoviePlayerPlaybackDidFinishNotification 
        object:player]; 
} 
+0

我試過了,沒有設置全屏和控制樣式 – 2010-07-19 15:52:10

回答

1

MPMoviePlayerController沒有視圖屬性。 您應該/必須使用 MPMoviePlayerViewController

這裏是我做的:

 moviePlayerViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:currentChannel.StreamURI]]; 

    [moviePlayerViewController.moviePlayer setControlStyle:MPMovieControlStyleNone]; 
    moviePlayerViewController.moviePlayer.movieSourceType = MPMovieSourceTypeStreaming; 
    moviePlayerViewController.moviePlayer.shouldAutoplay = YES; 
    [moviePlayerViewController.moviePlayer setScalingMode: MPMovieScalingModeAspectFit]; 
    moviePlayerViewController.view.frame = CGRectMake(0, 0, 480, 320); 


    [self.view addSubview:moviePlayerViewController.view]; 

注意,你可能想movieSourceType改變MPMovieSourceTypeFile或MPMovieSourceTypeUnknown。 上面的代碼是什麼,我需要打一個電影(在我的情況下,流道)

+0

是的,它是?!?!使用它IM在另一個視圖控制器,其在http://developer.apple.com/iphone/library/documentation/MediaPlayer/Reference/MPMoviePlayerController_Class/MPMoviePlayerController/MPMoviePlayerController.html#//apple_ref/doc/uid/TP40006953-引用CH3-SW49 – 2010-07-19 15:11:54

+0

但也許我應該使用,我將有一個去...... – 2010-07-19 15:12:45

+0

哦」我非常抱歉,爲您提供了誤導性信息.. – samsam 2010-07-19 15:14:20

1

在我來說,100%我搬到了

[window makeKeyAndVisible]; 

走出

didFinishLaunchingWithOptions 

並進入我的

movieDidFinish 

把它放回原處

相關問題