This commit is contained in:
18401019693 2022-07-26 10:06:16 +08:00
parent 8a9083f9b5
commit 8280e43a46
2 changed files with 22 additions and 3 deletions

View File

@ -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;
}
}

View File

@ -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