IMSDK
IM features a comprehensive suite of solutions including global access, one-to-one chat, group chat, message push, profile and relationship chain hosting, and account authentication. It also provides complete app access and backend management APIs.
V2TIMSoundElem

Public Member Functions

String getPath ()
 
String getUUID ()
 
int getDataSize ()
 
int getDuration ()
 
void downloadSound (String path, final V2TIMDownloadCallback v2TIMDownloadCallback)
 
void getUrl (final V2TIMValueCallback< String > callback)
 
void convertVoiceToText (String language, final V2TIMValueCallback< String > callback)
 
String toString ()
 
V2TIMElem getNextElem ()
 
void appendElem (V2TIMElem v2TIMElem)
 

Member Function Documentation

◆ getPath()

String getPath ( )
inline

Get the path of the audio file to be sent (can only be called by the message sender)

Returns
Path of audio file

◆ getUUID()

String getUUID ( )
inline

Get the internal ID of a voice message

Returns

◆ getDataSize()

int getDataSize ( )
inline

Get the voice data size

Returns

◆ getDuration()

int getDuration ( )
inline

Get the voice duration (seconds)

Returns

◆ downloadSound()

void downloadSound ( String  path,
final V2TIMDownloadCallback  v2TIMDownloadCallback 
)
inline

Download audio. This API downloads data from the server. To cache or store the data, you can use the UUID as the key. The Chat SDK does not store the files.

Parameters
pathThe path to which the audio file is saved. It must be specified externally.
v2TIMDownloadCallbackCallback

◆ getUrl()

void getUrl ( final V2TIMValueCallback< String >  callback)
inline

Get the voice download URL

◆ convertVoiceToText()

void convertVoiceToText ( String  language,
final V2TIMValueCallback< String >  callback 
)
inline

Convert the voice to text (supported only in 7.4 and later versions).

Parameters
languageThe language of the voice recognized.
Attention
  • Converting voice to text is a paid value-added feature and is now in beta testing. To try the feature, join our Tencent Cloud IM Group.

◆ toString()

String toString ( )
inline

◆ getNextElem()

V2TIMElem getNextElem ( )
inlineinherited

◆ appendElem()

void appendElem ( V2TIMElem  v2TIMElem)
inlineinherited

Add the next element

To configure multiple elements, after creating a Message object, you can add the next element via the element object of Message.

The following is the sample code for creating V2TIMTextElem and V2TIMCustomElem:

V2TIMMessage message = V2TIMManager.getMessageManager().createTextMessage("test");

V2TIMCustomElem customElem = new V2TIMCustomElem();

customElem.setData("Custom message".getBytes());

message.getTextElem().appendElem(customElem);

Attention
  • This API can be called only by elements of a Message object created via createMessage.
  • This API can be used to add V2TIMTextElem, V2TIMCustomElem, V2TIMFaceElem, or V2TIMLocationElem.