• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

ios - 加载 ICarousel 的 MPMovieControl 无法正常工作

[复制链接]
菜鸟教程小白 发表于 2022-12-12 11:00:05 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

我正在尝试实现视频 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 个视频,并且如果可能的话,在聚焦时加载它们。

从个人经验来看,我觉得这将是每个项目被绘制到屏幕上的方式,我只是无法解决这个问题。

非常感谢任何帮助!



Best Answer-推荐答案


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

关于ios - 加载 ICarousel 的 MPMovieControl 无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25108527/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap