How to check a file is video or image?

会有一股神秘感。 提交于 2019-12-13 06:31:45

问题


I am developing a chat app using parse. I want to play the vodeo when users click on the video message and Display expandable image when the user click on the picture message. for that I need to differentiate image and video. Kindly guide me to do that...


回答1:


Surely the easiest way will be of course to look at the file extension...?




回答2:


For future googlers ... on didTapMessageBubbleAtIndexPath delegate you should check for item class

let message = yourMessageArray[indexPath.item]

if message.isMediaMessage() {
    if message.media().isKindOfClass(JSQPhotoMediaItem) {
         //Handle image
    } else if message.media().isKindOfClass(JSQVideoMediaItem) {
         let video = message.media() as! JSQVideoMediaItem
         let videoURL = video.fileURL
    }
}



回答3:


Save this information in another field on Parse during the asset upload.



来源:https://stackoverflow.com/questions/31582717/how-to-check-a-file-is-video-or-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!