0

MPMoviePlayerController を使用して埋め込みビデオ ファイルを再生する際に問題が発生しています。私のコード:

 NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectoryPath = [paths objectAtIndex:0];

NSString *proud = [[documentsDirectoryPath stringByAppendingPathComponent:@"archives"] stringByAppendingPathComponent:selectedCountry];

NSString *content = [proud stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];    
NSURL *url = [[NSURL fileURLWithPath:content] retain];   

NSLog(@"%@", url);
player =

[[MPMoviePlayerController alloc] initWithContentURL: url];

[player prepareToPlay];

player.allowsAirPlay = YES;
player.scalingMode = MPMovieScalingModeAspectFit;

player.view.frame = self.view.frame;

[self.view addSubview: player.view];
[player setFullscreen:YES animated:YES];

// ...

[[NSNotificationCenter defaultCenter] 
 addObserver:self
 selector:@selector(movieFinishedCallback:)
 name:MPMoviePlayerPlaybackDidFinishNotification
 object:player];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(exitedFullscreen:) name:MPMoviePlayerDidExitFullscreenNotification object:player];


[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(moviePlayerWillExitFullscreen:)
                                             name:MPMoviePlayerWillExitFullscreenNotification
                                           object:player];


[player play];

NSLog が返す

var/mobile/Applications/EF62B00B-2906-435C-BC84-036FE14D89E9/Documents/archives/Test%2520-%2520Daddy%2520May%25201%252001:26:35%2520PM.mp4

MPMoviePlayerController MovieFinished Callback で使用するログから MovieDone がトリガーされますが、ビデオは再生されません。何かご意見は?

4

2 に答える 2

2

ビデオファイルのみを再生してから、次のコードを試してください:

NSString *urlStr=[[NSBundle mainBundle]pathForResource:@"Video1VoiceOver.mp4" ofType:nil];
NSURL *url = [NSURL fileURLWithPath:urlStr];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
[self.view addSubview:moviePlayer.view];
moviePlayer.view.frame = CGRectMake(174,154,720,428);  
[moviePlayer play];




[[NSNotificationCenter defaultCenter] addObserver:self 
                                         selector:@selector(moviePlayBackDidFinish) 
                                             name:MPMoviePlayerPlaybackDidFinishNotification 
                                           object:nil];
于 2012-05-02T05:22:05.843 に答える
0

これを試して

MPMoviePlayerViewController *playerViewController =[[MPMoviePlayerViewController alloc]initWithContentURL:[NSURL fileURLWithPath:@"FileName"]];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieFinishedCallback:)name:MPMoviePlayerPlaybackDidFinishNotification object:[playerViewController moviePlayer]];
playerViewController.view.frame=CGRectMake(Set the frame);
[self.view addSubview:playerViewController.view];
//---play movie---

player = [playerViewController moviePlayer];
于 2012-05-02T05:12:39.713 に答える