createSoundMessageFromFullPath
Description
info
Create an audio message. The SDK extracts audio information based on the absolute path and creates the audio message internally.
- iOS
- Android
- Flutter
- uni-app
- Browser/Electron/MiniProgram
- React-Native
- Unity
Function Prototype
Future<Message> createSoundMessageFromFullPath({
required String soundPath,
required int duration,
String? operationID,
})
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| soundPath | String | Yes | Absolute path |
| duration | int | Yes | Duration |
Return Result
| Name | Type | Description |
|---|---|---|
| ~ | Message | Success return |
Code Example
Message msg = await OpenIM.iMManager.messageManager.createSoundMessageFromFullPath(soundPath: soundPath, duration: duration);
//todo
Function Prototype
+ (OIMMessageInfo *)createSoundMessageFromFullPath:(NSString *)soundPath
duration:(NSInteger)duration;
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| soundPath | NSString | Yes | Absolute path |
| duration | NSInteger | Yes | Duration |
Return Result
| Name | Type | Description |
|---|---|---|
| message | OIMMessageInfo | Success return |
Code Example
OIMMessageInfo *message = [OIMMessageInfo createSoundMessageFromFullPath:@"" duration:1];
Function Prototype
public Message createSoundMessageFromFullPath(String soundPath, long duration)
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| soundPath | String | Yes | Absolute path |
| duration | int | Yes | Duration |
Return Result
| Name | Type | Description |
|---|---|---|
| ~ | Message | Success return |
Code Example
Message Message= OpenIMClient.getInstance().messageManager.createSoundMessageFromFullPath( soundPath, duration)
Note
Only supported when called using ffi in electron.
On the Web side, it is recommended to use createSoundMessageByURL or createSoundMessageByFile.
Function Prototype
IMSDK.createSoundMessageFromFullPath({
soundPath: string,
duration: number
}, operationID?: string): Promise<WsResponse<MessageItem>>
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| soundPath | string | Yes | File path, absolute path |
| duration | number | Yes | Audio duration, in seconds |
Return Result
| Parameter Name | Parameter Type | Description |
|---|---|---|
| Promise.then() | Promise<WsResponse<MessageItem>> | Success callback |
| Promise.catch() | Promise<WsResponse> | Failure callback |
Code Example
import { getWithRenderProcess } from '@openim/electron-client-sdk/lib/render';
const { instance: IMSDK } = getWithRenderProcess();
IMSDK.createSoundMessageFromFullPath({
soundPath: 'file://...',
duration: 9
})
.then(({ data }) => {
// Call successful
})
.catch(({ errCode, errMsg }) => {
// Call failed
});
Function Prototype
IMSDK.asyncApi('createSoundMessageFromFullPath', operationID: string, {
soundPath: string,
duration: number
}): Promise<MessageItem>
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| operationID | string | Yes | Operation ID, used to pinpoint issues, keep unique, prefer time+random |
| soundPath | string | Yes | Absolute file path |
| duration | number | Yes | Recording duration |
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('createSoundMessageFromFullPath', IMSDK.uuid(), {
soundPath: 'soundPath',
duration: 6,
})
.then((data) => {
// Call successful
})
.catch(({ errCode, errMsg }) => {
// Call failed
});
Function Prototype
OpenIMSDK.createSoundMessageFromFullPath({
soundPath: string,
duration: number,
}, operationID?: string): Promise<MessageItem>
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| soundPath | string | Yes | Absolute file path |
| duration | number | Yes | Recording duration |
| 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.createSoundMessageFromFullPath({
soundPath: 'soundPath',
duration: 6,
})
.then((data) => {
// Call successful
})
.catch((error) => {
// Call failed
});
Function Prototype
public static Message CreateSoundMessageFromFullPath(string soundPath, long duration);
Input Parameters
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| soundPath | string | Yes | Absolute path |
| duration | long | Yes | Duration |
Return Result
| Name | Type | Description |
|---|---|---|
| message | Message | Success return |
Code Example
var msg = IMSDK.CreateSoundMessageFromFullPath(sourcePath,duration);