How can I differentiate between image and video file types in Metafield?

Hi if i can select a metafield type File and check both the value image and video
now i did not understand on which base i can seperate them.
how i can access them

here is code that i can try it is working fine if i can upload a image but i cant understand how i can get the video
code:

it work fine but if the user select the video so how i can access it any suggestion how i can differentiate on the base of file type.
if there is video it show the video and if user select the imaage it display the image
please help

You can look at the media type. It will return image for images, and generic_file for everything else. That should be good enough for you to know that’s a video in your example. The file extension would also give you a very strong indicator of the file type.

i understand the type but could you right a few line of code according to given contion it very helpful for me thanks