createVideoMessageByURL
Description
info
When you need to store resources yourself, upload the video and thumbnail via API, obtain the download URLs, and then create a video message.
Note
Messages created through this API must be sent via 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 | Parameter Type | Required | Description |
|---|---|---|---|
| videoElem | VideoElem | Yes | Video address |
Return Result
| Name | Type | Description |
|---|---|---|
| ~ | Message | Success 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 | Parameter Type | Required | Description |
|---|---|---|---|
| fileURL | NSString | Yes | Video URL |
| videoType | NSString | No | Video type |
| duration | NSInteger | Yes | Duration |
| size | NSInteger | Yes | File size |
| snapshotPath | NSString | No | Video thumbnail URL |
Return Result
| Name | Type | Description |
|---|---|---|
| message | OIMMessageInfo | Success 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 | Parameter Type | Required | Description |
|---|---|---|---|
| videoElem | VideoElem | Yes | Video address |
Return Result
| Name | Type | Description |
|---|---|---|
| ~ | Message | Success return |
Code Example
Message Message= OpenIMClient.getInstance().messageManager. createVideoMessageByURL(videoElem)
Function Prototype
IMSDK.createFileMessageByURL({
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, empty string is fine |
| duration | number | Yes | Video duration |
| videoType | string | Yes | File type, usually the extension |
| snapshotPath | string | Yes | Video thumbnail path, empty string is fine |
| videoUUID | string | Yes | Unique video file ID |
| videoUrl | string | Yes | Video download URL. When uploading the file yourself and sending via sendMessageNotOss, this needs to be the remote URL; otherwise, it should be an empty string |
| videoSize | number | Yes | File size |
| snapshotUUID | string | Yes | Unique video thumbnail ID |
| snapshotSize | number | Yes | Video thumbnail size |
| snapshotUrl | string | Yes | Video thumbnail download URL. When uploading the file yourself and sending via sendMessageNotOss, this needs to be the remote URL; otherwise, it should be an empty string |
| snapshotWidth | number | Yes | Video thumbnail width |
| snapshotHeight | number | Yes | Video thumbnail height |
| snapShotType | string | Yes | Video thumbnail type, usually the extension |
Return Result
| Parameter Name | Parameter Type | Description |
|---|---|---|
| Promise.then() | Promise<WsResponse<MessageItem>> | Success callback |
| Promise.catch() | Promise<WsResponse> | Failure callback |
Code Example
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.createFileMessageByURL({
videoPath: '',
duration: 6,
videoType: 'mp4',
snapshotPath: '',
videoUUID: '',
videoUrl: '',
videoSize: 1024,
snapshotUUID: '',
snapshotSize: 1024,
snapshotUrl: '',
snapshotWidth: 1024,
snapshotHeight: 1024,
snapShotType: 'png',
})
.then(({ data }) => {
// Call successful
})
.catch(({ errCode, errMsg }) => {
// Call failed
});
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 to pinpoint issues, keep unique, prefer time+random |
| videoPath | string | Yes | File path, empty string is fine |
| duration | number | Yes | Video duration |
| videoType | string | Yes | File type, usually the extension |
| snapshotPath | string | Yes | Video thumbnail path, empty string is fine |
| videoUUID | string | Yes | Unique video file ID |
| videoUrl | string | Yes | Video download URL. When uploading the file yourself and sending via sendMessageNotOss, this needs to be the remote URL; otherwise, it should be an empty string |
| videoSize | number | Yes | File size |
| snapshotUUID | string | Yes | Unique video thumbnail ID |
| snapshotSize | number | Yes | Video thumbnail size |
| snapshotUrl | string | Yes | Video thumbnail download URL. When uploading the file yourself and sending via sendMessageNotOss, this needs to be the remote URL; otherwise, it should be an empty string |
| snapshotWidth | number | Yes | Video thumbnail width |
| snapshotHeight | number | Yes | Video thumbnail height |
| snapShotType | string | Yes | Video thumbnail type, usually the extension |
Return Result
Use the
openim-uniapp-polyfillpackage to make the function Promise. When calling, you need to usethenandcatchto determine and handle success and failure callbacks.
| Parameter Name | Parameter Type | Description |
|---|---|---|
| Promise.then() | Promise<MessageItem> | Success callback |
| Promise.catch() | Promise<CatchResponse> | Failure callback |
Code Example
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) => {
// Call successful
})
.catch(({ errCode, errMsg }) => {
// Call failed
});
Function Prototype
OpenIMSDK.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 |
|---|---|---|---|
| videoPath | string | Yes | File path, empty string is fine |
| duration | number | Yes | Video duration |
| videoType | string | Yes | File type, usually the extension |
| snapshotPath | string | Yes | Video thumbnail path, empty string is fine |
| videoUUID | string | Yes | Unique video file ID |
| videoUrl | string | Yes | Video download URL. When uploading the file yourself and sending via sendMessageNotOss, this needs to be the remote URL; otherwise, it should be an empty string |
| videoSize | number | Yes | File size |
| snapshotUUID | string | Yes | Unique video thumbnail ID |
| snapshotSize | number | Yes | Video thumbnail size |
| snapshotUrl | string | Yes | Video thumbnail download URL. When uploading the file yourself and sending via sendMessageNotOss, this needs to be the remote URL; otherwise, it should be an empty string |
| snapshotWidth | number | Yes | Video thumbnail width |
| snapshotHeight | number | Yes | Video thumbnail height |
| snapShotType | string | Yes | Video thumbnail type, usually the extension |
| operationID | string | No | Operation ID, used to pinpoint issues, keep unique, prefer time+random |
Return Result
| Parameter Name | Parameter Type | Description |
|---|---|---|
| Promise.then() | Promise<MessageItem> | Success callback |
| Promise.catch() | Promise<OpenIMApiError> | Failure callback |
Code Example
import OpenIMSDK from "@openim/rn-client-sdk";
OpenIMSDK.createVideoMessageByURL({
videoPath: '',
duration: 6,
videoType: 'mp4',
snapshotPath: '',
videoUUID: '',
videoUrl: '',
videoSize: 1024,
snapshotUUID: '',
snapshotSize: 1024,
snapshotUrl: '',
snapshotWidth: 1024,
snapshotHeight: 1024,
snapShotType: 'png',
})
.then((data) => {
// Call successful
})
.catch((error) => {
// Call failed
});
Function Prototype
public static Message CreateVideoMessageByURL(VideoElem videoBaseInfo)
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| videoBaseInfo | VideoElem | Yes | Video address |
Return Result
| Name | Type | Description |
|---|---|---|
| ~ | Message | Success return |
Code Example
var msg = IMSDK.CreateVideoMessageByURL(new VideoBaseInfo(){
});