createVideoMessageByURL
Feature Introduction
Description
When you need to store resources yourself, create a video message to send to the other party after uploading the video and thumbnail via the API and obtaining the download address.
Note
Messages created using this API must be sent through sendMessageNotOss.
- iOS
- Android
- Flutter
- uni-app
- Browser/Electron/MiniProgram
- React-Native
- Unity
Function Prototype
Future<Message> createVideoMessageByURL({
required VideoElem videoElem,
String? operationID,
})
Input Parameters
| Parameter Name | Data Type | Mandatory | Description |
|---|---|---|---|
| videoElem | VideoElem | Yes | Video address |
Return Result
| Name | Data Type | Description |
|---|---|---|
| ~ | Message | Successful return |
Code Example
Message msg = await OpenIM.iMManager.messageManager.createVideoMessageByURL(videoElem: videoElem);
//todo
Function Prototype
+ (OIMMessageInfo *)createVideoMessageByURL:(NSString *)fileURL
videoType:(NSString * _Nullable)videoType
duration:(NSInteger)duration
size:(NSInteger)size
snapshot:(NSString * _Nullable)snapshotURL
Input Parameters
| Parameter Name | Data Type | Mandatory | Description |
|---|---|---|---|
| fileURL | NSString | Yes | Video address |
| videoType | NSString | No | Video type |
| duration | NSInteger | Yes | Duration |
| size | NSInteger | Yes | Duration |
| snapshotPath | NSString | No | Video thumbnail address |
Return Result
| Name | Data Type | Description |
|---|---|---|
| message | OIMMessageInfo | Successful return |
Code Example
OIMMessageInfo *message = [OIMMessageInfo createVideoMessageByURL:@"" videoType:nil duration:1 size:1024 snapshot:nil];
Function Prototype
public Message createVideoMessageByURL(VideoElem videoElem)
Input Parameters
| Parameter Name | Data Type | Mandatory | Description |
|---|---|---|---|
| videoElem | VideoElem | Yes | Video address |
Return Result
| Name | Data Type | Description |
|---|---|---|
| ~ | Message | Successful return |
Code Example
Message Message= OpenIMClient.getInstance().messageManager. createVideoMessageByURL(videoElem)
Function Prototype
IMSDK.createVideoMessage({
videoPath: string;
duration: number;
videoType: string;
snapshotPath: string;
videoUUID: string;
videoUrl: string;
videoSize: number;
snapshotUUID: string;
snapshotSize: number;
snapshotUrl: string;
snapshotWidth: number;
snapshotHeight: number;
snapShotType: string;
}, operationID?: string): Promise<WsResponse<MessageItem>>
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| videoPath | string | Yes | File path, can be an empty string |
| duration | number | Yes | Video duration |
| videoType | string | Yes | File type, usually the file extension |
| snapshotPath | string | Yes | Path of the video thumbnail, can be an empty string |
| videoUUID | string | Yes | Unique ID for the video file |
| videoUrl | string | Yes | Video download URL. If uploaded yourself and sent through sendMessageNotOss, enter the remote URL. Otherwise, use an empty string. |
| videoSize | number | Yes | File size |
| snapshotUUID | string | Yes | Unique ID for the video thumbnail |
| snapshotSize | number | Yes | Size of the video thumbnail |
| snapshotUrl | string | Yes | Download URL for the video thumbnail. If uploaded yourself and sent through sendMessageNotOss, enter the remote URL. Otherwise, use an empty string. |
| snapshotWidth | number | Yes | Width of the thumbnail |
| snapshotHeight | number | Yes | Height of the thumbnail |
| snapShotType | string | Yes | Type of the thumbnail, usually the file extension |
Return Results
| Parameter Name | Parameter Type | Description |
|---|---|---|
| Promise.then() | Promise<WsResponse<MessageItem>> | Success callback |
| Promise.catch() | Promise<WsResponse> | Failure callback |
Code Sample
import { getSDK } from '@openim/wasm-client-sdk';
const IMSDK = getSDK();
// use in electron with ffi
// import { getWithRenderProcess } from '@openim/electron-client-sdk/lib/render';
// const { instance: IMSDK } = getWithRenderProcess();
// use in mini program
// import { getSDK } from '@openim/client-sdk';
// const IMSDK = getSDK();
IMSDK.createVideoMessage({
videoPath: '',
duration: 6,
videoType: 'mp4',
snapshotPath: '',
videoUUID: '',
videoUrl: '',
videoSize: 1024,
snapshotUUID: '',
snapshotSize: 1024,
snapshotUrl: '',
snapshotWidth: 1024,
snapshotHeight: 1024,
snapShotType: 'png',
})
.then(({ data }) => {
// Success
})
.catch(({ errCode, errMsg }) => {
// Failure
});
Function Prototype
IMSDK.asyncApi('createVideoMessageByURL', operationID: string, {
videoPath: string;
duration: number;
videoType: string;
snapshotPath: string;
videoUUID: string;
videoUrl: string;
videoSize: number;
snapshotUUID: string;
snapshotSize: number;
snapshotUrl: string;
snapshotWidth: number;
snapshotHeight: number;
snapShotType: string;
}): Promise<MessageItem>
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| operationID | string | Yes | Operation ID, used for issue tracking. It's unique and it's recommended to combine the current time with a random number. |
| videoPath | string | Yes | File path, can be an empty string |
| duration | number | Yes | Video duration |
| videoType | string | Yes | File type, usually the file extension |
| snapshotPath | string | Yes | Path of the video thumbnail, can be an empty string |
| videoUUID | string | Yes | Unique ID for the video file |
| videoUrl | string | Yes | Video download URL. If uploaded yourself and sent through sendMessageNotOss, enter the remote URL. Otherwise, use an empty string. |
| videoSize | number | Yes | File size |
| snapshotUUID | string | Yes | Unique ID for the video thumbnail |
| snapshotSize | number | Yes | Size of the video thumbnail |
| snapshotUrl | string | Yes | Download URL for the video thumbnail. If uploaded yourself and sent through sendMessageNotOss, enter the remote URL. Otherwise, use an empty string. |
| snapshotWidth | number | Yes | Width of the thumbnail |
| snapshotHeight | number | Yes | Height of the thumbnail |
| snapShotType | string | Yes | Type of the thumbnail, usually the file extension |
Return Results
Using the
openim-uniapp-polyfillpackage makes the function return a Promise. When calling, usethenandcatchto handle and check the success and failure callbacks.
| Parameter Name | Parameter Type | Description |
|---|---|---|
| Promise.then() | Promise<MessageItem> | Success callback |
| Promise.catch() | Promise<CatchResponse> | Failure callback |
Code Sample
import IMSDK from 'openim-uniapp-polyfill';
IMSDK.asyncApi('createVideoMessageByURL', IMSDK.uuid(), {
videoPath: '',
duration: 6,
videoType: 'mp4',
snapshotPath: '',
videoUUID: '',
videoUrl: '',
videoSize: 1024,
snapshotUUID: '',
snapshotSize: 1024,
snapshotUrl: '',
snapshotWidth: 1024,
snapshotHeight: 1024,
snapShotType: 'png',
})
.then((data) => {
// Success
})
.catch(({ errCode, errMsg }) => {
// Failure
});
Function Prototype
OpenIMSDKRN.createVideoMessageByURL({
videoPath: string,
duration: number,
videoType: string,
snapshotPath: string,
videoUUID: string,
videoUrl: string,
videoSize: number,
snapshotUUID: string,
snapshotSize: number,
snapshotUrl: string,
snapshotWidth: number,
snapshotHeight: number,
snapShotType: string,
}, operationID: string): Promise<MessageItem>
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| operationID | string | Yes | Operation ID, used for issue tracking. It's unique and it's recommended to combine the current time with a random number. |
| videoPath | string | Yes | File path, can be an empty string |
| duration | number | Yes | Video duration |
| videoType | string | Yes | File type, usually the file extension |
| snapshotPath | string | Yes | Path of the video thumbnail, can be an empty string |
| videoUUID | string | Yes | Unique ID for the video file |
| videoUrl | string | Yes | Video download URL. If uploaded yourself and sent through sendMessageNotOss, enter the remote URL. Otherwise, use an empty string. |
| videoSize | number | Yes | File size |
| snapshotUUID | string | Yes | Unique ID for the video thumbnail |
| snapshotSize | number | Yes | Size of the video thumbnail |
| snapshotUrl | string | Yes | Download URL for the video thumbnail. If uploaded yourself and sent through sendMessageNotOss, enter the remote URL. Otherwise, use an empty string. |
| snapshotWidth | number | Yes | Width of the thumbnail |
| snapshotHeight | number | Yes | Height of the thumbnail |
| snapShotType | string | Yes | Type of the thumbnail, usually the file extension |
Return Result
| Parameter Name | Parameter Type | Description |
|---|---|---|
| Promise.then() | Promise<MessageItem> | Callback on successful call |
| Promise.catch() | Promise<CatchResponse> | Callback on failed call |
Code Example
import OpenIMSDKRN from "open-im-sdk-rn";
OpenIMSDKRN.createVideoMessageByURL({
videoPath: '',
duration: 6,
videoType: 'mp4',
snapshotPath: '',
videoUUID: '',
videoUrl: '',
videoSize: 1024,
snapshotUUID: '',
snapshotSize: 1024,
snapshotUrl: '',
snapshotWidth: 1024,
snapshotHeight: 1024,
snapShotType: 'png',
}, 'operationID')
.then((data) => {
// Success
})
.catch(({ errCode, errMsg }) => {
// Failure
});
Function Prototype
public static Message CreateVideoMessageByURL(VideoBaseInfo videoBaseInfo)
Input Parameter
| Parameter Name | Parameter Type | Mandatory | Description |
|---|---|---|---|
| videoBaseInfo | VideoBaseInfo | Yes | Video Setting |
Return Result
| Parameter Name | Type | Description |
|---|---|---|
| ~ | Message | Message Struct |
Code Example
var msg = IMSDK.CreateVideoMessageByURL(new VideoBaseInfo(){
});