How to get thumbnail from video URL in Swift 5


If you want to show video in your app and you want to show thumbnail. The easy way is to get image url from server API. But there is more easy way you just need to get url video and get image url. I have searched on the internet but what I found my app becomes lag. I use UITableview to show the video thumbnail url.

Maybe you wonder why I use image thumbnail. I can use video player from iOS and thumbnail video will be shown. But what if you use many thumbnail in UITableview, it will be heavy in the device. It's bad design too.

It will be good for you, if you can combine this extension image with SDWebImage. Because the image will be in cache and you don't need to reload image again. But you still need the internet to load the video url. Because it's online from the internet.

This is swift code and about objective-c code, it's better you search on the internet. I know it's really painful to change it to swift if you have developed big app. So you can convert swift to objective-c but it's not sure there will be a match library between swift and objective-c.




Thanks for samuel. I got this code from him on stackoverflow. This is the link https://stackoverflow.com/a/55531065/2899321

It uses extenstion to get url show. It will make your design code more simple. Don't forget put the extension in seperated file to make your source code easy to manage.

If you have any question please feel free to ask. Thanks for visiting my simple website. GG

Popular posts from this blog

How to have ConstraintLayout inside ScrollView and ScrollView inside ConstraintLayout Android

Missing system image Android Studio solution

Fixing Keyboard Hide When Reload UITableview iOS swift 5