Search in sources :

Example 1 with EMVideoMessageBody

use of com.hyphenate.chat.EMVideoMessageBody in project SmartCampus by Vegen.

the class EaseChatVideoPresenter method onBubbleClick.

@Override
public void onBubbleClick(EMMessage message) {
    EMVideoMessageBody videoBody = (EMVideoMessageBody) message.getBody();
    EMLog.d(TAG, "video view is on click");
    if (EMClient.getInstance().getOptions().getAutodownloadThumbnail()) {
    } else {
        if (videoBody.thumbnailDownloadStatus() == EMFileMessageBody.EMDownloadStatus.DOWNLOADING || videoBody.thumbnailDownloadStatus() == EMFileMessageBody.EMDownloadStatus.PENDING || videoBody.thumbnailDownloadStatus() == EMFileMessageBody.EMDownloadStatus.FAILED) {
            // retry download with click event of user
            EMClient.getInstance().chatManager().downloadThumbnail(message);
            return;
        }
    }
    Intent intent = new Intent(getContext(), EaseShowVideoActivity.class);
    intent.putExtra("msg", message);
    if (message != null && message.direct() == EMMessage.Direct.RECEIVE && !message.isAcked() && message.getChatType() == EMMessage.ChatType.Chat) {
        try {
            EMClient.getInstance().chatManager().ackMessageRead(message.getFrom(), message.getMsgId());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    getContext().startActivity(intent);
}
Also used : Intent(android.content.Intent) EMVideoMessageBody(com.hyphenate.chat.EMVideoMessageBody)

Example 2 with EMVideoMessageBody

use of com.hyphenate.chat.EMVideoMessageBody in project SmartCampus by Vegen.

the class EaseChatRowVideo method onSetUpView.

@Override
protected void onSetUpView() {
    EMVideoMessageBody videoBody = (EMVideoMessageBody) message.getBody();
    String localThumb = videoBody.getLocalThumb();
    if (localThumb != null) {
        showVideoThumbView(localThumb, imageView, videoBody.getThumbnailUrl(), message);
    }
    if (videoBody.getDuration() > 0) {
        String time = DateUtils.toTime(videoBody.getDuration());
        timeLengthView.setText(time);
    }
    if (message.direct() == EMMessage.Direct.RECEIVE) {
        if (videoBody.getVideoFileLength() > 0) {
            String size = TextFormater.getDataSize(videoBody.getVideoFileLength());
            sizeView.setText(size);
        }
    } else {
        if (videoBody.getLocalUrl() != null && new File(videoBody.getLocalUrl()).exists()) {
            String size = TextFormater.getDataSize(new File(videoBody.getLocalUrl()).length());
            sizeView.setText(size);
        }
    }
    EMLog.d(TAG, "video thumbnailStatus:" + videoBody.thumbnailDownloadStatus());
    if (message.direct() == EMMessage.Direct.RECEIVE) {
        if (videoBody.thumbnailDownloadStatus() == EMFileMessageBody.EMDownloadStatus.DOWNLOADING || videoBody.thumbnailDownloadStatus() == EMFileMessageBody.EMDownloadStatus.PENDING) {
            imageView.setImageResource(R.drawable.ease_default_image);
        } else {
            // System.err.println("!!!! not back receive, show image directly");
            imageView.setImageResource(R.drawable.ease_default_image);
            if (localThumb != null) {
                showVideoThumbView(localThumb, imageView, videoBody.getThumbnailUrl(), message);
            }
        }
        return;
    } else {
        if (videoBody.thumbnailDownloadStatus() == EMFileMessageBody.EMDownloadStatus.DOWNLOADING || videoBody.thumbnailDownloadStatus() == EMFileMessageBody.EMDownloadStatus.PENDING || videoBody.thumbnailDownloadStatus() == EMFileMessageBody.EMDownloadStatus.FAILED) {
            progressBar.setVisibility(View.INVISIBLE);
            percentageView.setVisibility(View.INVISIBLE);
            imageView.setImageResource(R.drawable.ease_default_image);
        } else {
            progressBar.setVisibility(View.GONE);
            percentageView.setVisibility(View.GONE);
            imageView.setImageResource(R.drawable.ease_default_image);
            showVideoThumbView(localThumb, imageView, videoBody.getThumbnailUrl(), message);
        }
    }
}
Also used : EMVideoMessageBody(com.hyphenate.chat.EMVideoMessageBody) File(java.io.File)

Example 3 with EMVideoMessageBody

use of com.hyphenate.chat.EMVideoMessageBody in project SmartCampus by Vegen.

the class EaseShowVideoActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.ease_showvideo_activity);
    loadingLayout = (RelativeLayout) findViewById(R.id.loading_layout);
    progressBar = (ProgressBar) findViewById(R.id.progressBar);
    final EMMessage message = getIntent().getParcelableExtra("msg");
    if (!(message.getBody() instanceof EMVideoMessageBody)) {
        Toast.makeText(EaseShowVideoActivity.this, "Unsupported message body", Toast.LENGTH_SHORT).show();
        finish();
        return;
    }
    EMVideoMessageBody messageBody = (EMVideoMessageBody) message.getBody();
    localFilePath = messageBody.getLocalUrl();
    if (localFilePath != null && new File(localFilePath).exists()) {
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(Uri.fromFile(new File(localFilePath)), "video/mp4");
        startActivity(intent);
        finish();
    } else {
        EMLog.d(TAG, "download remote video file");
        downloadVideo(message);
    }
}
Also used : Intent(android.content.Intent) EMVideoMessageBody(com.hyphenate.chat.EMVideoMessageBody) File(java.io.File) EMMessage(com.hyphenate.chat.EMMessage)

Aggregations

EMVideoMessageBody (com.hyphenate.chat.EMVideoMessageBody)3 Intent (android.content.Intent)2 File (java.io.File)2 EMMessage (com.hyphenate.chat.EMMessage)1