Video Post

Create Video Post

Creating a video post is similar to creating a file and image post.
First, you need to upload the videos using AmityFileRepostory , build the post using AmityVideoPostCreator.Builder, and then finally create the post.
AmityFileRepository class contains a method that helps in uploading videos. To upload videos, you have to specify the feedType that the video should belong.
For example: If you want to create a video post, you need to set feedType to post or ContentFeedType.POST
When the video is successfully uploaded, you will receive an instance of AmityVideoData which contains information about the uploaded video.

Requirements for Videos

  • Supported video types are 3gp, avi, f4v, flv, m4v, mov, mp4, ogv, 3g2, wmv, vob, webm, mkv
  • The maximum file size of the video is 1 GB
  • The maximum duration of the video is 2 hours
  • Thumbnail for video post will be automatically generated
When creating a video post, you need to upload the video first so you can get the fileId that you will use in creating the video post.
After uploading the video, you can now create the video post.
Refer to Post target type for a more detailed explanation of the targetType parameter.
Many videos can be added into one video post. Currently, SDK has the maximum of ten videos per post.

Create a Video Post with Mention

You can mention users in a post. The sample code below shows how to create a video post with mention.

Play Video

The actual videos in a video post can be found by looking at the children posts.
import { PostRepository, PostDataType } from '@amityco/js-sdk';
...
async function getPost(postId) {
return new Promise(resolve => {
const liveObject = PostRepository.postForId(postId);
liveObject.once('dataUpdated', data => {
resolve(data);
liveObject.dispose();
});
});
}
const post = await getPost(postId);
const postChildren = await Promise.all(post.children.map(getPost));
const postVideoChild = postChildren
.filter(child => child.dataType === PostDataType.Video)[0];
To integrate with UI, SDK provides thumbnailFileId to show a video poster and videoFileId, a set of ids for videos of different quality.
async function getFile(fileId) {
return new Promise(resolve => {
const liveObject = FileRepository.getFile(postVideoChild.fileId);
liveObject.once('dataUpdated', data => {
resolve(data);
liveObject.dispose();
});
});
}
const file = await getFile(postVideoChild.data.thumbnailFileId);
// http url of the thumbnail
file.fileUrl
const highQualityVideoFile = await getFile(postVideoChild.data.videoFileId.high);
// http url of the video file
file.fileUrl

Available Video Qualities

After a video post is created, the videos will be transcoded from the original quality.
Currently, the SDK provides one original quality, and three transcoded quality. The possible qualities are :
'original'
'high'
'medium'
'low'
When you create a video post, the original quality will be available immediately after the post is created. However, the transcoded quality will take time, and will be available eventually.
SDK provides qualities in data.videoFileId.
Export as PDF
Copy link
Outline
Create Video Post
Create a Video Post with Mention
Play Video
Available Video Qualities