-1

I'm working on an app that's similar to YouTube functionalities. Now I need to display a list of videos (already stored in Firebase) in a collectionView and I need to get the duration of each video. I'm considering to

  1. add a property duration to struct Post and just get it easily when loading the posts.

  2. create an object of AVURLAsset from the url of the video and get the duration from asset.duration. However, my intuition tells me this second option is not that good an idea.

I'm now in the very early stage of my career as an iOS developer; I badly need a solution to this problem. Thanks!

David Wu
  • 105
  • 2
  • 13

1 Answers1

2

I would add the duration property (perhaps as a double in seconds) when uploading the video -- it would hardly take up any storage, and it is easy to fetch and parse.