我正在尝试实现视频 URL 的 iCarousel,以允许用户查看其他帖子。 现在我不得不说我喜欢 iCarousel,这是我唯一的问题。
我显示了正确数量的轮播对象,并且播放按钮都在所有这些对象上,尽管我一次只接收一个视频并且控件无法正确播放视频。
我有一个保存 _videoURLS
的 NSMutableArray,这是我提供需要通过 [_videoURLS count];
在我的 .m 文件中,这是我使用轮播对象准备视频播放器的方式
- (UIView *)carouseliCarousel *)carousel viewForItemAtIndexNSUInteger)index reusingViewUIView *)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 actionselector(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 selectorselector(didFinishPlaying name:MPMoviePlayerPlaybackDidFinishNotification object:_player];
return view;
}
如果我在轮播中有一个对象并且只能处理一个视频,它会很好地工作,我必须能够在轮播上处理 10 个视频,并且如果可能的话,在聚焦时加载它们。
从个人经验来看,我觉得这将是每个项目被绘制到屏幕上的方式,我只是无法解决这个问题。
非常感谢任何帮助!
根据苹果文档,我发现这是无法完成的,我选择使用 AVFoundation 框架
关于ios - 加载 ICarousel 的 MPMovieControl 无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25108527/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |