Viewing Video Message

Playing a message with video

To play a video, the SDK provides the function AmityVideoData.getVideo(resolution:), which returns a ready-to-play HTTP URL.​

Available Video Resolutions

After a video message is created, the videos are transcoded from the original resolution. AmityVideoResolution is an enum that represents the video resolution. When you create a video message, the original resolution is available immediately after the message is created. However, the transcoded resolution takes time and will only be available later. You can use the property AmityVideoData.videoUrls to get the available resolution for the current message.​

Video Data Attributes

The SDK provides AmityVideoData.attributes, which returns a dictionary of video file attributes that might be useful for your application.​

Video Thumbnail Image

let fileRepository = AmityFileRepository(client: client)
    ...
    
    func downloadVideoThumbnailAsData(from message: AmityMessage) {
        guard let thumbnailFileId = message.data?["thumbnailFileId"] as? String,
              !thumbnailFileId.isEmpty,
              let imageInfo = message.getVideoThumbnailImageInfo() else { return }
        
        
        // Download from url and return saved image url.
        fileRepository.downloadImage(fromURL: imageInfo.fileURL, size: .small) { imageUrl, error in
            // Handle image url and error.
        }
    }
    
    func downloadVideoThumbnailAsUIImage(from message: AmityMessage) {
        guard let thumbnailFileId = message.data?["thumbnailFileId"] as? String,
              !thumbnailFileId.isEmpty,
              let imageInfo = message.getVideoThumbnailImageInfo() else { return }
        
        // Download from url and return image.
        fileRepository.downloadImageAsData(fromURL: imageInfo.fileURL, size: .small) { image, size, error in
            // Handle image and error.
        }
    }

Last updated