Ios 为ICarousel加载MPMovieControl无法正常工作

Ios 为ICarousel加载MPMovieControl无法正常工作,ios,objective-c,video,mpmovieplayercontroller,icarousel,Ios,Objective C,Video,Mpmovieplayercontroller,Icarousel,我正在尝试实现视频URL的iCarousel,以允许用户查看其他帖子。 现在我不得不说我爱伊卡鲁塞尔,这是我唯一的问题 虽然我一次只接收一个视频,而且控件没有正确播放视频,但我有正确数量的旋转木马对象显示,并且所有对象上都有播放按钮 我有一个NSMutableArray,它保存着\u videoURLS,在这里我通过[\u videoURLS count]提供需要的旋转木马对象的数量 在我的.m文件中,这是我准备带旋转木马对象的视频播放器的方式 - (UIView *)carousel:(iC

我正在尝试实现视频URL的iCarousel,以允许用户查看其他帖子。 现在我不得不说我爱伊卡鲁塞尔,这是我唯一的问题

虽然我一次只接收一个视频,而且控件没有正确播放视频,但我有正确数量的旋转木马对象显示,并且所有对象上都有播放按钮

我有一个NSMutableArray,它保存着
\u videoURLS
,在这里我通过
[\u videoURLS count]提供需要的旋转木马对象的数量

在我的.m文件中,这是我准备带旋转木马对象的视频播放器的方式

 - (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view

 {

 if (view == nil)

  {   

    UIView *mainView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200.0f, 370.0f)];

    view = mainView;

    CGFloat mainViewWidth = mainView.bounds.size.width;



    //Video Player View

    _videoView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, mainViewWidth, 220)];

    _videoView.backgroundColor = [UIColor colorWithRed:123/255.0 green:123/255.0 blue:123/255.0 alpha:1.0];

    _videoView.center = CGPointMake(100, 170);

    _videoView.tag = 7;

    [view addSubview:_videoView];



    //video

    _player = [[MPMoviePlayerController alloc] init];

    [_player.view setFrame:_videoView.bounds];

    [_player prepareToPlay];

    [_player setShouldAutoplay:NO];

    _player.scalingMode = MPMovieScalingModeAspectFit;

    _player.controlStyle = MPMovieControlStyleNone;

    [_videoView addSubview:_player.view]; 



    //Play Button

    _playButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 60.0f, 60.0f)];

    [_playButton setBackgroundImage:[UIImage imageNamed:@"play-icon-grey.png"] forState:UIControlStateNormal];

    [_playButton addTarget:self.view.superview action:@selector(postThread:) forControlEvents:UIControlEventTouchUpInside];

    _playButton.center = CGPointMake(100, 160);

    _playButton.tag = 3;

    [view addSubview:_playButton];      

}

else

{

    //get a reference to the label in the recycled view

    _playButton = (UIButton *) [view viewWithTag:3];

    _videoView = (UIView *) [view viewWithTag:7];

}

//Setting Video For Each Carousel

for (int i = 0; i < 9; i++) {

    [_player setContentURL:[NSURL URLWithString:[_videoURLS objectAtIndex:index]]];

    NSLog(@"Object Link: %@",[_videoURLS objectAtIndex:index]);

}    

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didFinishPlaying:) name:MPMoviePlayerPlaybackDidFinishNotification object:_player];

return view;

}
-(UIView*)旋转木马:(iCarousel*)旋转木马视图for ItemAtIndex:(nsInteger)索引重用视图:(UIView*)视图
{
如果(视图==nil)
{   
UIView*mainView=[[UIView alloc]initWithFrame:CGRectMake(0,0,200.0f,370.0f)];
视图=主视图;
CGFloat mainViewWidth=mainView.bounds.size.width;
//视频播放器视图
_videoView=[[UIView alloc]initWithFrame:CGRectMake(0,0,mainViewWidth,220)];
_videoView.backgroundColor=[UIColor color withred:123/255.0绿色:123/255.0蓝色:123/255.0 alpha:1.0];
_videoView.center=CGPointMake(100170);
_videoView.tag=7;
[视图添加子视图:\视频视图];
//录像带
_player=[[MPMoviePlayerController alloc]init];
[\u player.view setFrame:\u videoView.bounds];
[_playerpreparetoplay];
[_播放器设置应自动播放:否];
_player.scalingMode=MPMovieScalingModeAspectFit;
_player.controlStyle=MPMovieControlStyleNone;
[\u videoView addSubview:\u player.view];
//播放按钮
_playButton=[[UIButton alloc]initWithFrame:CGRectMake(0,0,60.0f,60.0f)];
[\u playButton setBackgroundImage:[UIImage ImageName:@“play icon grey.png”]用于状态:UIControlStateNormal];
[\u playButton addTarget:self.view.superview操作:@selector(postThread:)forControlEvents:UIControlEventTouchUpInside];
_playButton.center=CGPointMake(100160);
_playButton.tag=3;
[查看添加子视图:_播放按钮];
}
其他的
{
//获取对回收视图中标签的引用
_playButton=(UIButton*)[查看带有标记的视图:3];
_videoView=(UIView*)[带标签的视图:7];
}
//为每个旋转木马设置视频
对于(int i=0;i<9;i++){
[\u player setContentURL:[NSURL URLWithString:[\u videoURLS objectAtIndex:index]];
NSLog(@“对象链接:%@,[\u videoURLS objectAtIndex:index]);
}    
[[NSNotificationCenter defaultCenter]添加观察者:自选择器:@selector(DidFinishPlay:)名称:MPMoviePlayerPlaybackDidFinishNotification对象:_player];
返回视图;
}
如果我在旋转木马中有一个对象,并且只能处理一个视频,我必须能够处理旋转木马上的10个视频,如果可能的话,在聚焦时加载它们

根据我个人的经验,我觉得这是每个项目被吸引到屏幕上的方式,我只是无法了解这个问题


非常感谢您的帮助

根据苹果的文档,我发现这是无法做到的,我选择使用AVFoundation框架

我真的需要一些帮助,我甚至可以使用skype并尝试一起完成……我明天就需要它!任何帮助!!您可以将buttons标记设置为carousel viewtag的索引,然后在单击按钮播放该索引的对象时从该索引开始。@JitenParmar我刚刚尝试过,得到了相同的结果您可以给出_playbutton.tag=index然后-(void)btnPlay:(UIButton*)然后你还必须给_player提供索引,然后当你点击按钮时获得_player控件,然后播放it@JitenParmar我相信我知道你在说什么,请帮帮我