Ios5 当用户在uipickerview中选择视频名称时,如何在完成一个视频后播放另一个视频
我的目标是将视频文件放入Ios5 当用户在uipickerview中选择视频名称时,如何在完成一个视频后播放另一个视频,ios5,video,mpmovieplayercontroller,Ios5,Video,Mpmovieplayercontroller,我的目标是将视频文件放入uipicker。我已经在一个数组中添加了我的视频文件名,并成功提取了视频文件名和扩展名,但现在我的目标是当用户点击选择器行时,从数组中选择的视频将被传递到mpmovieplayercontroller对象,然后该对象将播放电影。请告诉我如何编写代码来播放另一个视频完成一个文件后选择的文件,即在1MP中完成 下面是我播放单个视频文件的代码 请告诉我如何播放阵列中的其他视频: -(IBAction)play:(id)sender { for (i = 0;i<[arr
uipicker
。我已经在一个数组中添加了我的视频文件名,并成功提取了视频文件名和扩展名,但现在我的目标是当用户点击选择器行时,从数组中选择的视频将被传递到mpmovieplayercontroller
对象,然后该对象将播放电影。请告诉我如何编写代码来播放另一个视频完成一个文件后选择的文件,即在1MP中完成
下面是我播放单个视频文件的代码
请告诉我如何播放阵列中的其他视频:
-(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
}
-(iAction)播放:(id)发送方
{
对于(i=0;i,您需要重新构造代码
您发布的代码从视频路径名数组中生成路径名,然后使用@“filename”的固定文件名。这是不对的
您应该编写一个方法“playFileAtIndex”,在特定索引处查找文件名并播放该文件。我建议在该方法中添加BOOL参数playMultipleVideos。如果该标志为true,该方法将设置movieFinishedCallback以增加索引并开始下一部电影播放
然后让button iAction方法为所选行设置索引iVar,并调用playFileAtIndex方法