createSoundMessageFromFullPath
Feature Introduction
Note
Create an audio message. The SDK internally extracts audio information based on the full path and creates an audio message.
- 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 | Mandatory | 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 | Mandatory | 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 | Mandatory | 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)
Caution
For the Web platform, it's recommended to use createSoundMessageByURL or createSoundMessageByFile.
Function Prototype
IMSDK.asyncApi('createSoundMessageFromFullPath', operationID: string, {
soundPath: string,
duration: number
}): Promise<MessageItem>
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
operationID | string | Yes | Operation ID, used for problem tracking, suggested to use current time and a random number |
soundPath | string | Yes | File absolute path |
duration | number | Yes | Recording duration |
Return Result
Using the
openim-uniapp-polyfill
package makes the function return a Promise. You'll need to usethen
andcatch
to handle the success and failure callbacks respectively.
Parameter Name | 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 succeeded
})
.catch(({ errCode, errMsg }) => {
// Call failed
});
Function Prototype
OpenIMSDKRN.createSoundMessageFromFullPath({
soundPath: string,
duration: number,
}, operationID: string): Promise<MessageItem>
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
soundPath | string | Yes | File absolute path |
duration | number | Yes | Recording duration |
operationID | string | Yes | Operation ID, used for problem location, keep unique, suggest using current time and random number |
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.createSoundMessageFromFullPath({
soundPath: 'soundPath',
duration: 6,
}, 'operationID')
.then((data) => {
// Call succeeded
})
.catch(({ errCode, errMsg }) => {
// Call failed
});
Function Prototype
public static Message CreateSoundMessageFromFullPath(string soundPath, long duration);
Input Parameter
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
soundPath | string | Yes | File absolute path |
duration | long | Yes | Recording duration |
Return Result
Parameter Name | Type | Description |
---|---|---|
message | Message | Message Struct |
Code Example
var msg = IMSDK.CreateSoundMessageFromFullPath(sourcePath,duration);