com.hyphenate.chat.EMVideoMessageBody Java Examples

The following examples show how to use com.hyphenate.chat.EMVideoMessageBody. 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: EaseChatRowVideo.java    From Social with Apache License 2.0 6 votes vote down vote up
@Override
protected void onBubbleClick() {
    EMVideoMessageBody videoBody = (EMVideoMessageBody) message.getBody();
       EMLog.d(TAG, "video view is on click");
       Intent intent = new Intent(context, EaseShowVideoActivity.class);
       intent.putExtra("localpath", videoBody.getLocalUrl());
       intent.putExtra("secret", videoBody.getSecret());
       intent.putExtra("remotepath", videoBody.getRemoteUrl());
       if (message != null && message.direct() == EMMessage.Direct.RECEIVE && !message.isAcked()
               && message.getChatType() == ChatType.Chat) {
           try {
               EMClient.getInstance().chatManager().ackMessageRead(message.getFrom(), message.getMsgId());
           } catch (Exception e) {
               e.printStackTrace();
           }
       }
       activity.startActivity(intent);
}
 
Example #2
Source File: EaseChatRowVideo.java    From Study_Android_Demo with Apache License 2.0 6 votes vote down vote up
@Override
protected void onBubbleClick() {
    EMVideoMessageBody videoBody = (EMVideoMessageBody) message.getBody();
       EMLog.d(TAG, "video view is on click");
       Intent intent = new Intent(context, EaseShowVideoActivity.class);
       intent.putExtra("localpath", videoBody.getLocalUrl());
       intent.putExtra("secret", videoBody.getSecret());
       intent.putExtra("remotepath", videoBody.getRemoteUrl());
       if (message != null && message.direct() == EMMessage.Direct.RECEIVE && !message.isAcked()
               && message.getChatType() == ChatType.Chat) {
           try {
               EMClient.getInstance().chatManager().ackMessageRead(message.getFrom(), message.getMsgId());
           } catch (Exception e) {
               e.printStackTrace();
           }
       }
       activity.startActivity(intent);
}
 
Example #3
Source File: VideoMessageBaseItemView.java    From FamilyChat with Apache License 2.0 5 votes vote down vote up
@Override
public void setMessageData(RcvHolder holder, final EMMessage emMessage, final int position)
{
    SelectableRoundedImageView imgThumb = holder.findView(R.id.img_chat_listitem_video_content);
    TextView tvDuration = holder.findView(R.id.tv_chat_listitem_video_content_duration);
    TextView tvFileLength = holder.findView(R.id.tv_chat_listitem_video_content_filelength);

    EMVideoMessageBody messageBody = (EMVideoMessageBody) emMessage.getBody();

    //缩略图
    String localThumb = messageBody.getLocalThumb();
    String remoteThumb = messageBody.getThumbnailUrl();
    if (StringUtil.isNotEmpty(localThumb) && new File(localThumb).exists())
        CommonUtils.getInstance().getImageDisplayer()
                .display(mContext, imgThumb, localThumb, 240, 300);
    else
        CommonUtils.getInstance().getImageDisplayer()
                .display(mContext, imgThumb, remoteThumb, 240, 300);
    //视频时长
    String durationEx = mContext.getResources().getString(R.string.tv_chat_listitem_video_duration_Ex);
    String duration = durationEx.replaceFirst("%%1", String.valueOf(messageBody.getDuration()));
    tvDuration.setText(duration);
    //视频大小
    tvFileLength.setText(formetFileSize(messageBody.getVideoFileLength()));

    //点击播放
    holder.setClickListener(R.id.img_chat_listitem_video_start, new View.OnClickListener()
    {
        @Override
        public void onClick(View v)
        {
            mPresenter.clickVideoMessage(emMessage, position);
        }
    });
    setMessage(holder, emMessage, position);
}
 
Example #4
Source File: HxShortVideoPlayPresenter.java    From FamilyChat with Apache License 2.0 5 votes vote down vote up
/**
 * 初始化视频数据
 */
public void initData(EMMessage message)
{
    String msgId = message.getMsgId();
    EMVideoMessageBody messageBody = (EMVideoMessageBody) message.getBody();
    //检查文件是否存在本地文件
    String localUrl = messageBody.getLocalUrl();
    if (new File(localUrl).exists())
    {
        //存在就直接播放
        mViewImpl.startPlayVideo(localUrl);
        return;
    }

    //检查是否下载过
    ShortVideoBean videoBean = mModel.queryDataByMsgId(msgId);
    if (videoBean == null)
    {
        //没有下载过就直接下载
        downLoadRemoteUrlVideo(msgId, messageBody.getRemoteUrl());
    } else
    {
        //下载过就检查文件是否还在
        String downLoadUrl = videoBean.getLocal_url();
        if (new File(downLoadUrl).exists())
        {
            //下载的文件存在就直接播放
            mViewImpl.startPlayVideo(downLoadUrl);
        } else
        {
            //下载的文件不存在就重新下载
            ShortVideoDao.getInstance().delete(videoBean);
            downLoadRemoteUrlVideo(msgId, messageBody.getRemoteUrl());
        }
    }
}