问题
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