com.easemob.chat.VoiceMessageBody Java Examples

The following examples show how to use com.easemob.chat.VoiceMessageBody. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ChatActivity.java    From school_shop with MIT License 6 votes vote down vote up
/**
 * 发送语音
 * 
 * @param filePath
 * @param fileName
 * @param length
 * @param isResend
 */
private void sendVoice(String filePath, String fileName, String length, boolean isResend) {
	if (!(new File(filePath).exists())) {
		return;
	}
	try {
		final EMMessage message = EMMessage.createSendMessage(EMMessage.Type.VOICE);
		// 如果是群聊,设置chattype,默认是单聊
		if (chatType == CHATTYPE_GROUP)
			message.setChatType(ChatType.GroupChat);
		message.setReceipt(toChatUsername);
		int len = Integer.parseInt(length);
		VoiceMessageBody body = new VoiceMessageBody(new File(filePath), len);
		message.addBody(body);

		conversation.addMessage(message);
		adapter.refreshSelectLast();
		setResult(RESULT_OK);
		// send file
		// sendVoiceSub(filePath, fileName, message);
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
Example #2
Source File: EaseChatRowVoicePlayClickListener.java    From monolog-android with MIT License 5 votes vote down vote up
public EaseChatRowVoicePlayClickListener(EMMessage message, ImageView v, ImageView iv_read_status, BaseAdapter adapter, Activity context) {
	this.message = message;
	voiceBody = (VoiceMessageBody) message.getBody();
	this.iv_read_status = iv_read_status;
	this.adapter = adapter;
	voiceIconView = v;
	this.activity = context;
	this.chatType = message.getChatType();
}
 
Example #3
Source File: ChatActivity.java    From FanXin-based-HuanXin with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 发送语音
 * 
 * @param filePath
 * @param fileName
 * @param length
 * @param isResend
 */
private void sendVoice(String filePath, String fileName, String length,
        boolean isResend) {
    if (!(new File(filePath).exists())) {
        return;
    }
    try {
        final EMMessage message = EMMessage
                .createSendMessage(EMMessage.Type.VOICE);

        // 如果是群聊,设置chattype,默认是单聊
        if (chatType == CHATTYPE_GROUP)
            message.setChatType(ChatType.GroupChat);
        message.setReceipt(toChatUsername);
        message.setAttribute("toUserNick", toUserNick);
        message.setAttribute("toUserAvatar", toUserAvatar);
        message.setAttribute("useravatar", myUserAvatar);
        message.setAttribute("usernick", myUserNick);
        int len = Integer.parseInt(length);
        VoiceMessageBody body = new VoiceMessageBody(new File(filePath),
                len);
        message.addBody(body);

        conversation.addMessage(message);
        adapter.refresh();
        listView.setSelection(listView.getCount() - 1);
        setResult(RESULT_OK);
        // send file
        // sendVoiceSub(filePath, fileName, message);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example #4
Source File: VoicePlayClickListener.java    From FanXin-based-HuanXin with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 
 * @param message
 * @param v
 * @param iv_read_status
 * @param context
 * @param activity
 * @param user
 * @param chatType
 */
public VoicePlayClickListener(EMMessage message, ImageView v, ImageView iv_read_status, BaseAdapter adapter, Activity activity,
		String username) {
	this.message = message;
	voiceBody = (VoiceMessageBody) message.getBody();
	this.iv_read_status = iv_read_status;
	this.adapter = adapter;
	voiceIconView = v;
	this.activity = activity;
	this.chatType = message.getChatType();
}
 
Example #5
Source File: VoicePlayClickListener.java    From school_shop with MIT License 5 votes vote down vote up
/**
 * 
 * @param message
 * @param v
 * @param iv_read_status
 * @param context
 * @param activity
 * @param user
 * @param chatType
 */
public VoicePlayClickListener(EMMessage message, ImageView v, ImageView iv_read_status, BaseAdapter adapter, Activity activity,
		String username) {
	this.message = message;
	voiceBody = (VoiceMessageBody) message.getBody();
	this.iv_read_status = iv_read_status;
	this.adapter = adapter;
	voiceIconView = v;
	this.activity = activity;
	this.chatType = message.getChatType();
}