2

I have videos that I want to display in table view cells. These are the requirements:

  • Each video is only 10 seconds long.
  • Each video will come from the internet (i.e. will not be local).
  • This is important: I want the videos to autoplay and keep looping. So a user does not have to press a play button to see it. Basically all the videos will be playing and looping over and over as the user scrolls through the table.
  • I will fetch 7 videos to display on the table. When a user reaches the end of the table, the could press a button "Load More" to make a network request for an additional 7 videos.

Any ideas on how to embed a video player into the table view cell and have them play?

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
JEL
  • 1,540
  • 4
  • 23
  • 51

1 Answers1

2

If you create a custom UITableViewCell, you can add a AVPlayer object to that cell and load it up with a video (some code you can use to start with can be found in this related question).

To be honest though, do not expect responsive or fast UI in your table view if you have 7 videos playing at the same time. This is going to be very taxing on the device (in terms of CPU and battery). And each time the "more" button is touched (to add more videos), you might get even slower performance (mitigated only by if you code things in a friendly way -- e.g. where the player stops when the cell is scrolled offscreen).

Community
  • 1
  • 1
Michael Dautermann
  • 88,797
  • 17
  • 166
  • 215