2011-12-15 7 views
2

私はこれを試してもうまくいきません。私は音が聞こえますが、イメージは見えません。どうすればこの問題を解決できますか?アプリデリゲートクラスで目的地のビデオを再生する

:video.mクラスで

- (IBAction)tanitimVideo:(id)sender { 
// create our UnifeyeMobileViewController and present it 
video* unifeyeMobileViewController = [[video alloc] initWithNibName:@"video" bundle:nil]; 
unifeyeMobileViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; 
[viewController presentModalViewController:unifeyeMobileViewController animated:YES]; 
[unifeyeMobileViewController release]; 

} 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
// Do any additional setup after loading the view from its nib. 

NSBundle *bundle = [NSBundle mainBundle]; 
NSString *moviePath = [bundle pathForResource:@"debutteaser" ofType:@"mp4"]; 
NSURL *movieURL = [[NSURL fileURLWithPath:moviePath] retain]; 
MPMoviePlayerController *theMovie = [[MPMoviePlayerController alloc] initWithContentURL:movieURL]; 
theMovie.scalingMode = MPMovieScalingModeAspectFill; 
[theMovie play]; 
MPMoviePlayerViewController *moviePlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:movieURL]; 
[self presentMoviePlayerViewControllerAnimated:moviePlayer]; 
} 

答えて

1

それが働いて取得すると、あなたからそれをすべて行うことができますMPMoviePlayerViewController代わりに、非常にわずかなコードを使用してみてくださいあなたのアプリデリゲート;)

- (IBAction)tanitimVideo:(id)sender { 
    NSBundle *bundle = [NSBundle mainBundle]; 

    NSString *moviePath = [bundle pathForResource:@"debutteaser" ofType:@"mp4"]; 

    MPMoviePlayerViewController *mp = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:moviePath]]; 

    mp.moviePlayer.scalingMode = MPMovieScalingModeAspectFill; 

    [self presentMoviePlayerViewControllerAnimated:mp]; 

    [mp release]; 
} 
+0

なぜあなたはリリースを呼び出しますか? –

1

R .Mファイル -

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
// Do any additional setup after loading the view from its nib. 

NSBundle *bundle = [NSBundle mainBundle]; 
NSString *moviePath = [bundle pathForResource:@"debutteaser" ofType:@"mp4"]; 
NSURL *movieURL = [[NSURL fileURLWithPath:moviePath] retain]; 
MPMoviePlayerController *theMovie = [[MPMoviePlayerController alloc] initWithContentURL:movieURL]; 
theMovie.scalingMode = MPMovieScalingModeAspectFill; 
[theMovie play]; 

////////// <<<<<>>>>>>>>>> ////////// 

MPMoviePlayerViewController *moviePlayer = [[MPMoviePlayerViewController alloc] 
initWithContentURL:movieURL]; 
[self presentMoviePlayerViewControllerAnimated:moviePlayer]; 

} 

は、なぜあなたは2つのコントローラ(theMovie、のMoviePlayer)を作るのですか、あなたはtheMovie内のすべての設定が、のMoviePlayerを実行しています。

、それはこのようにする必要があります: - (無効)のviewDidLoad { [スーパーのviewDidLoad]; //ペン先からビューをロードした後に追加設定を行います。

NSBundle *bundle = [NSBundle mainBundle]; 
NSString *moviePath = [bundle pathForResource:@"debutteaser" ofType:@"mp4"]; 
NSURL *movieURL = [[NSURL fileURLWithPath:moviePath] retain]; 
MPMoviePlayerController *theMovie = [[MPMoviePlayerController alloc] initWithContentURL:movieURL]; 
theMovie.scalingMode = MPMovieScalingModeAspectFill; 
[theMovie setShouldAutoplay:YES]; 
[self presentMoviePlayerViewControllerAnimated:theMovie]; 

} 

願っています。

関連する問題