Play video on UITableViewCell when it is completely visible

后端 未结 3 1330
半阙折子戏
半阙折子戏 2020-12-03 02:26

I have an Array which contains video URLS, I want to play those videos on UITableviewcell when it is fully visible.

I have tried this

- (void)scroll         


        
3条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-03 02:54

    Avoid reloading the table view every time you want to play a video. You can perform your video playing code on the visible cell without having to reload the entire tableview.

    Also, I suspect you don't really want to play the video until after the table view has stopped scrolling. See How to detect when a UIScrollView has finished scrolling (detecting when a UIScrollView is finished scrolling is surprisingly not intuitive).

    If you do really want to start playing the video before the scrollview stops scrolling, at least modify your code to check if the visible cell is already playing, then do nothing. Right now your tableView:cellForRowAtIndexPath: code that plays a video is executed many, many times whenever a cell is fully visible (which I suspect happens a lot!).

提交回复
热议问题