im::floo::floolib::BMXVoiceAttachment

Audio attachment

Inherits from im.floo.floolib.BMXFileAttachment, im.floo.floolib.BMXMessageAttachment, BMXBaseObject

Public Functions

Name
synchronized void delete()
BMXVoiceAttachment(String path, int duration, String displayName)
Constructor to build the audio attachment to send
BMXVoiceAttachment(String path, int duration)
BMXVoiceAttachment(String ratelUrl, int duration, String displayName, long fileLength)
Constructor to build the audio attachment to receive
BMXMessageAttachment.Type type()
Type of returned file
BMXMessageAttachment clone()
Cloning function
int duration()
Length of speech
BMXVoiceAttachment dynamic_cast(BMXMessageAttachment attachment)

Protected Functions

Name
BMXVoiceAttachment(long cPtr, boolean cMemoryOwn)
void finalize()
long getCPtr(BMXVoiceAttachment obj)

Additional inherited members

Public Functions inherited from im.floo.floolib.BMXFileAttachment

Name
BMXFileAttachment(String path, String displayName)
Constructor to build the message attachment of sent file
BMXFileAttachment(String path)
BMXFileAttachment(String ratelUrl, String displayName, long fileLength)
Constructor to build the message attachment of received file
String path()
Local path
String displayName()
Display name
String ratelUrl()
String url()
Remote URL
long fileLength()
File length
BMXMessageAttachment.DownloadStatus downloadStatus()
Attachment download state

Protected Functions inherited from im.floo.floolib.BMXFileAttachment

Name
BMXFileAttachment(long cPtr, boolean cMemoryOwn)

Protected Functions inherited from im.floo.floolib.BMXMessageAttachment

Name
BMXMessageAttachment(long cPtr, boolean cMemoryOwn)

Public Functions Documentation

function delete

inline synchronized void delete()

Reimplements: im::floo::floolib::BMXFileAttachment::delete

Example:

function BMXVoiceAttachment

inline BMXVoiceAttachment(
    String path,
    int duration,
    String displayName
)

Constructor to build the audio attachment to send

Parameters:

  • path Local path of file
  • duration Audio length
  • displayName Display name of file

Example:

function BMXVoiceAttachment

inline BMXVoiceAttachment(
    String path,
    int duration
)

Example:

function BMXVoiceAttachment

inline BMXVoiceAttachment(
    String ratelUrl,
    int duration,
    String displayName,
    long fileLength
)

Constructor to build the audio attachment to receive

Parameters:

  • ratelUrl ratel server address
  • duration Audio length
  • displayName Display name of file
  • fileLength File size

Example:

function type

inline BMXMessageAttachment.Type type()

Type of returned file

Return: Type

Reimplements: im::floo::floolib::BMXFileAttachment::type

Example:

function clone

inline BMXMessageAttachment clone()

Cloning function

Return: BMXMessageAttachmentPtr

Reimplements: im::floo::floolib::BMXFileAttachment::clone

Example:

function duration

inline int duration()

Length of speech

Return: int32_t

Example:

private void showVoice() {
    if (mMaxMessage == null || mMaxMessage.contentType() != BMXMessage.ContentType.Voice) {
        return;
    }
    BMXVoiceAttachment body = BMXVoiceAttachment.dynamic_cast(mMaxMessage.attachment());
    if (body == null) {
        return;
    }
    int voiceTime = body.duration();
    mVoiceTime.setText(voiceTime + "''");
    int width = ScreenUtils.dp2px((196 - 78) / 60 * voiceTime + 78);
    if (width > ScreenUtils.dp2px(196)) {
        width = ScreenUtils.dp2px(196);
    }
    RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)mFlChatVoice
            .getLayoutParams();
    params.width = width;
    params.height = ScreenUtils.dp2px(41);
    mFlChatVoice.setLayoutParams(params);
    messageBean.setH(h);
    return messageBean;
}
if (contentType == BMXMessage.ContentType.Voice) {
    // 语音
    BMXVoiceAttachment body = BMXVoiceAttachment.dynamic_cast(mBmxMessage.attachment());
    if (body == null || TextUtils.isEmpty(body.path())) {
        return null;
    }
    messageBean.setPath(body.path());
    messageBean.setDuration(body.duration());
    return messageBean;
}
if (contentType == BMXMessage.ContentType.File) {
    // 文件
    BMXFileAttachment body = BMXFileAttachment.dynamic_cast(mBmxMessage.attachment());
    if (body == null || TextUtils.isEmpty(body.path())) {
        return null;
    }
    messageBean.setPath(body.path());

function dynamic_cast

static inline BMXVoiceAttachment dynamic_cast(
    BMXMessageAttachment attachment
)

Reimplements: im::floo::floolib::BMXFileAttachment::dynamic_cast

Protected Functions Documentation

Example:

private void showVoice() {
    if (mMaxMessage == null || mMaxMessage.contentType() != BMXMessage.ContentType.Voice) {
        return;
    }
    BMXVoiceAttachment body = BMXVoiceAttachment.dynamic_cast(mMaxMessage.attachment());
    if (body == null) {
        return;
    }
    int voiceTime = body.duration();
    mVoiceTime.setText(voiceTime + "''");
    int width = ScreenUtils.dp2px((196 - 78) / 60 * voiceTime + 78);
    if (width > ScreenUtils.dp2px(196)) {
        width = ScreenUtils.dp2px(196);
    }
    RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)mFlChatVoice
            .getLayoutParams();
    params.width = width;
    params.height = ScreenUtils.dp2px(41);
    mFlChatVoice.setLayoutParams(params);
private void onAudioItemClick(final BMXMessage bean) {
    if (mView == null || bean == null || bean.contentType() != BMXMessage.ContentType.Voice) {
        return;
    }
    ackMessage(bean);
    final BMXVoiceAttachment body = BMXVoiceAttachment.dynamic_cast(bean.attachment());
    if (body == null) {
        return;
    }
    if (mVoicePlayHelper == null) {
        mVoicePlayHelper = new VoicePlayHelper((Activity)mView.getContext());
        registerSensor();
    }
    if (mVoicePlayHelper.isPlaying()) {
        stopVoicePlay();
        return;
    }
    if (TextUtils.isEmpty(body.path())) {
        Log.i(TAG, "http voiceUrl is null");
private void playVoice(String voicePath, final BMXMessage bean) {
    if (mView == null || TextUtils.isEmpty(voicePath) || bean == null
            || bean.contentType() != BMXMessage.ContentType.Voice || mVoicePlayHelper == null) {
        return;
    }
    BMXVoiceAttachment body = BMXVoiceAttachment.dynamic_cast(bean.attachment());
    if (body == null) {
        return;
    }
    mVoicePlayHelper.setOnVoiceFinishListener(new VoicePlayHelper.OnVoiceFinishListener() {
        @Override
        public void onFinish() {
            if (mView == null) {
                return;
            }
            VoicePlayManager.getInstance().onFinishCallback(bean);
            // mView.getVoiceMessageMsgId(chatBean.getMsgId());
        }

        @Override
    }
    int w = (int)body.size().getMWidth();
    int h = (int)body.size().getMHeight();
    messageBean.setPath(body.path());
    messageBean.setW(w);
    messageBean.setH(h);
    return messageBean;
}
if (contentType == BMXMessage.ContentType.Voice) {
    // 语音
    BMXVoiceAttachment body = BMXVoiceAttachment.dynamic_cast(mBmxMessage.attachment());
    if (body == null || TextUtils.isEmpty(body.path())) {
        return null;
    }
    messageBean.setPath(body.path());
    messageBean.setDuration(body.duration());
    return messageBean;
}
if (contentType == BMXMessage.ContentType.File) {
    // 文件

function BMXVoiceAttachment

inline BMXVoiceAttachment(
    long cPtr,
    boolean cMemoryOwn
)

Example:

function finalize

inline void finalize()

Reimplements: im::floo::floolib::BMXFileAttachment::finalize

Example:

function getCPtr

static inline long getCPtr(
    BMXVoiceAttachment obj
)

Example:


Updated on 2022-01-26 at 17:18:31 +0800

© 2019-2024 MaximTop | Homepage | Site Map Last modified time: 2024-09-26 03:17:35

results matching ""

    No results matching ""