Help Displaying mp4 Videos in Listview page of Posts with Images

Job ID: 36481278

Budget: $10 – $30 USD

Hi. I have a listview page in my iOS App (Swift) that displays image thumbnails and the title of a simple post. Some of the posts have an mp4 file instead of an image. I would love to be able to display the video thumbnail or something showing that it's a video IF that particular post has a video instead of an image.

Here's the code from the page (and I cannot share this source):

if let url = URL(string: videoDetails["image"] as! String ){
DispatchQueue.main.async {
SDWebImageManager.shared().downloadImage(with: url, options: .continueInBackground, progress: {
(receivedSize :Int, ExpectedSize :Int) in
videoThumbnail.image = UIImage(named: "loading_img")
}, completed: {
(image : UIImage?, error : Error?, cacheType : SDImageCacheType, finished : Bool, url : URL?) in
videoThumbnail.image = image
})
}
}

And here's the JSON API output that's being used to create the page - as you can see one of the items has an mp4 instead of image in the "image" parameter. I even have a "vid" parameter for specifying if the image is an mp4. This should make it easier to do an IF condition and then set the code to handle an image link or a video link.

Thanks!
Related categories: Mobile App Development iPhone Mac OS Swift Apple Xcode