From 8280e43a4656ec3cc89d7be4b449d382b34eb957 Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Tue, 26 Jul 2022 10:06:16 +0800 Subject: [PATCH] 11111 --- .../com/yunbao/common/utils/TimeUtils.java | 20 +++++++++++++++++++ .../live/views/InputPanelViewHolder.java | 5 ++--- 2 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 common/src/main/java/com/yunbao/common/utils/TimeUtils.java diff --git a/common/src/main/java/com/yunbao/common/utils/TimeUtils.java b/common/src/main/java/com/yunbao/common/utils/TimeUtils.java new file mode 100644 index 000000000..a19cf4576 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/utils/TimeUtils.java @@ -0,0 +1,20 @@ +package com.yunbao.common.utils; + +/** + * 时间处理 + */ +public class TimeUtils { + /** + * 毫秒转秒 + * @param duration 毫秒数 + * @return + */ + public static long durationToSecond(long duration) { + long toSecond = 0; + long seconds = duration % 60000; + long second = Math.round((float) seconds / 1000); + long minute = duration / 60000; + toSecond = ((minute * 60) + second); + return toSecond; + } +} diff --git a/live/src/main/java/com/yunbao/live/views/InputPanelViewHolder.java b/live/src/main/java/com/yunbao/live/views/InputPanelViewHolder.java index e62741fbf..cfe4b4941 100644 --- a/live/src/main/java/com/yunbao/live/views/InputPanelViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/InputPanelViewHolder.java @@ -17,6 +17,7 @@ import android.widget.LinearLayout; import androidx.annotation.Nullable; import com.yunbao.common.utils.FileUtil; +import com.yunbao.common.utils.TimeUtils; import com.yunbao.common.utils.ToastUtil; import com.yunbao.live.R; import com.yunbao.live.utils.FileSizeUtil; @@ -262,11 +263,9 @@ public class InputPanelViewHolder extends LinearLayout implements View.OnClickLi * @param duration 视频时长 */ private void sendSightExtension(String filePath, long duration) { - long seconds = duration % 60000 ; - long second = Math.round((float)seconds/1000) ; Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE; Uri localUri = Uri.parse("file://" + filePath); - SightMessage sightMessage = SightMessage.obtain(localUri, (int) second); + SightMessage sightMessage = SightMessage.obtain(localUri, (int) TimeUtils.durationToSecond(duration)); Message message = Message.obtain(targetId, conversationType, sightMessage); IMCenter.getInstance().sendMediaMessage(message, null, null, new IRongCallback.ISendMediaMessageCallback() { @Override