在像Instagram这样的tableview中使用多个AVPlayer [英] Using multiple AVPlayer in a tableview like instagram

查看:237
本文介绍了在像Instagram这样的tableview中使用多个AVPlayer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将AVPlayer实现到tableview单元格的每一行,但我找不到任何好的文档。我想有一个像Instagram这样的时间表,但我不知道如何处理多个玩家和里面的tapgest ..任何想法,我可以找到一些?

I'm trying to implement an AVPlayer into each row of a tableview cell but I don't find any good documentation. I would like to have a timeline like Instagram but I have no idea how to handle multiple players and tapgestures inside.. Any idea where I can find some?

推荐答案

我建议不要让所有单元格都包含玩家。真的没有理由因为你不会同时在屏幕上播放所有单元格(事实上我希望这不是计划)。

I would recommend not having all of the cells contain players. There really isn't a reason to as you aren't going to be playing all of the cells on screen at the same time (indeed I hope that isn't the plan).

相反,我希望每个单元格只包含一个图像,最好是第一帧或每个视频前几秒的某个地方。你最好已经拥有这些,但可以从视频中获取这些图像(单独的研究主题......)。

Instead, I would have each of the cells contain only an image, preferably of the first frame or somewhere in the first few seconds of each video. Preferably you have these already but it is possible to grab these images from the videos (separate research topic...).

然后,你可以简单地等待用户点击单元格(或图像上方的播放按钮),然后将单元格的内容转换为播放器而不是图像(并停止播放任何其他单元格)。这应该与所有单元格中的玩家基本相同,但需要较少的资源加载并允许更好的图像缓存。

Then, you could simply wait for the user to tap the cell (or a play button over the image) and then transition the contents of the cell to a player instead of the image (and stop any other cell from playing). This should look and work basically identically to players in all cells but requires less resource loading and allows better image caching.

这篇关于在像Instagram这样的tableview中使用多个AVPlayer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆