How to check a file is video or image?

2019-09-02 06:26发布

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...

3条回答
Luminary・发光体
2楼-- · 2019-09-02 06:58

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

查看更多
The star\"
3楼-- · 2019-09-02 07:01

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

查看更多
smile是对你的礼貌
4楼-- · 2019-09-02 07:11

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
    }
}
查看更多
登录 后发表回答