我的目标是将视频文件放在uipicker
. 我已在数组中添加了我的视频文件名并成功提取了视频文件名和扩展名,但现在我的目标是当用户点击选择器行时,从数组中选择的视频将被传递给mpmovieplayercontroller
对象,然后将播放电影请让我知道如何在一个文件完成后编写代码来播放另一个选定的文件,即 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
}