I am trying to download and play videos in a tableView like Instagram, vine or even facebook.
What I am trying to achieve is a tableView where I display the videos and they auto download and play while scrolling. Like Instagram...
So far I have managed most of that, but what I would like to change is the fact that every time I view a cell the video gets downloaded again and again.... Surely there must be a way to cache videos, or only download the same video once.... Like you do with SDWebImages for images.
Also at the moment with it download every time I view the cell, the scrolling is terrible as you can imagine.
Now I cannot seem to figure out how Instagram does it, but I am 100% sure they don't download the same video more than once!!
If anyone has and advice or ideas, I'd love to hear them!!
Many thanks in advance.
Using Haneke, I wasn't able to retrieve file path for cached video. I handled it by saving video in cached directory.
Sample usage of this class looks like this:
great question. You're best bet is to use something open-source and 3rd party on Github. I use them solely for images, but I believe they will load and cache videos for you as well. Here are the links to some popular ones...
https://github.com/onevcat/Kingfisher https://github.com/Haneke/HanekeSwift There is also a good list of libraries you might find useful... https://github.com/Wolg/awesome-swift
Hope this helps!