2009-07-28 10 views
1

私は動作するムービーファイルを持っています。私は、タブビューコントローラ内のnavコントローラの中にtableviewコントローラを追加しました。ユーザがテーブルビューのセルをクリックすると、ビデオビューがロードされます。それはムービーを起動し(シミュレータ内で回転します)、ビデオは再生されず、コントロールはポートレート表示用です。私は音が聞こえて、時間がコントロールで行くのを見ます。それは明らかに景観だけではありません。iphone 3.1 - MPMediaPlayerは、風景ではなく、奇妙な肖像画を表示します。

私はsetOrientationにいくつかのトリックを試みましたが、警告があって正しく機能しませんでした。
助けていただきありがとうございます。

#import "StreamViewController.h" 

@implementation StreamViewController 
@synthesize moviePlayer; 
@synthesize streamURL; 

// Override to allow orientations other than the default portrait orientation. 
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    // Return YES for supported orientations 
    return YES; 
} 
- (void)viewDidAppear:(BOOL)animated { 
    NSBundle *bundle = [NSBundle mainBundle]; 
    if (bundle) 
    { 
     NSString *moviePath = [bundle pathForResource:@"splash" ofType:@"m4v"]; 
     self.streamURL  = [NSURL fileURLWithPath:moviePath]; 
    } 

    moviePlayer    = [[MPMoviePlayerController alloc] initWithContentURL:[self streamURL]]; 
    moviePlayer.scalingMode = MPMovieScalingModeAspectFill; 
    [moviePlayer play]; 
    [super viewDidAppear:animated]; 
} 

- (void)dealloc { 
    [super dealloc]; 
} 

@end 

答えて

1

私は最初のものをリリースせずに複数のビデオプレーヤーを使用していたと思います。これを使用すると、常に1つのMPMoviePlayerControllerをアクティブに保つことができましたが、このアプローチで切り替えても効果がありました。

MPMoviePlayerController *mp = [[MPMoviePlayerController alloc] initWithContentURL:self.splashURL]; 
mp.scalingMode    = MPMovieScalingModeAspectFill; 
if (mp) 
{ 
    // save the movie player object 
    self.streamMoviePlayer = mp; 
    [mp release]; 


    // Play the movie! 
    [self.streamMoviePlayer play]; 
} 
関連する問題