私の目的は、ビデオファイルをuipicker
. ビデオファイル名を配列に追加し、ビデオファイル名と拡張子を正常に抽出しましたが、ユーザーがピッカーの行をタップすると、配列から選択されたビデオがmpmovieplayercontroller
オブジェクトに渡され、ムービーが再生されます。 1 つのファイルの完了後に別の選択されたファイルを再生するコードを作成する方法を知っています iein 1mpmovieplaybackfinished`
単一のビデオ ファイルを再生するための私のコードは以下のとおりです。
配列から別のビデオを再生する方法を教えてください:
-(IBAction)play:(id)sender
{
for (i = 0;i<[arrayofvideo count];i++) {<br /> NSLog(@"%d",i);
NSString *fullFileName = [NSString stringWithFormat:@"%@",[arrayofvideo objectAtIndex:i]];
NSString *filename = [fullFileName stringByDeletingPathExtension];
NSLog(@"%@",filename);
NSString *extension = [fullFileName pathExtension];
NSLog(@"%@",extension);
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]
pathForResource:@"filename"
ofType:@"extension"]];
movieplayer = [[MPMoviePlayerController alloc]initWithContentURL:url];
movieplayer.movieSourceType = MPMovieSourceTypeFile;
movieplayer.controlStyle = MPMovieControlStyleDefault;
movieplayer.view.frame = CGRectMake(0,0,300,400);
[self.view addSubview:movieplayer.view];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(movieFinishedCallback:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:movieplayer];
//---play movie---
[movieplayer play];
}
-(void)movieFinishedCallback:(NSNotification*) aNotification
{
MPMoviePlayerController *player = [aNotification object];
[[NSNotificationCenter defaultCenter]
removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:player];
[player stop];
// self.view removeFromSuperView;
[self.view removeFromSuperview];
//call the play button again
// pls tell me what to write here to call play function
}