[BugFix]解决试听声音只能到59秒的bug

This commit is contained in:
wushaocheng
2023-01-16 01:24:41 +08:00
parent 44da35d193
commit eb43a6c1b8
4 changed files with 18 additions and 12 deletions

View File

@@ -19,7 +19,7 @@ import lombok.Getter;
*/ */
public class AudioPlayerHelper { public class AudioPlayerHelper {
private final static long mIntervalTime = 500L; private final static long mIntervalTime = 100L;
public interface WHAT_STATUS { public interface WHAT_STATUS {
int ERROR = 1; int ERROR = 1;

View File

@@ -10,7 +10,6 @@ import com.yizhuan.erban.R
import com.yizhuan.erban.audio.SoundSignatureActivity import com.yizhuan.erban.audio.SoundSignatureActivity
import com.yizhuan.erban.audio.helper.AudioPlayerHelper import com.yizhuan.erban.audio.helper.AudioPlayerHelper
import com.yizhuan.erban.audio.helper.OnPlayListener import com.yizhuan.erban.audio.helper.OnPlayListener
import com.yizhuan.erban.audio.presenter.RecordingVoicePresenter
import com.yizhuan.erban.base.BaseViewModel import com.yizhuan.erban.base.BaseViewModel
import com.yizhuan.xchat_android_core.audio.AudioPlayAndRecordManager import com.yizhuan.xchat_android_core.audio.AudioPlayAndRecordManager
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager import com.yizhuan.xchat_android_core.manager.AvRoomDataManager
@@ -22,7 +21,6 @@ import com.yizhuan.xchat_android_library.utils.ResUtil
import com.yizhuan.xchat_android_library.utils.SingleToastUtil import com.yizhuan.xchat_android_library.utils.SingleToastUtil
import com.yizhuan.xchat_android_library.utils.log.MLog import com.yizhuan.xchat_android_library.utils.log.MLog
import java.io.File import java.io.File
import kotlin.math.roundToInt
/** /**
* @author wushaocheng * @author wushaocheng
@@ -135,7 +133,7 @@ class SoundViewModel : BaseViewModel() {
recordType: RecordType recordType: RecordType
) { ) {
val dura = audioLength.toDouble() / 1000 val dura = audioLength.toDouble() / 1000
audioDur = dura.roundToInt() audioDur = dura.toInt()
audioFile = file audioFile = file
Log.d( Log.d(
TAG, "onRecordSuccess : " + file.path TAG, "onRecordSuccess : " + file.path
@@ -287,8 +285,12 @@ class SoundViewModel : BaseViewModel() {
TAG, TAG,
"duration = $currDuration" "duration = $currDuration"
) )
if ((SoundSignatureActivity.MAX_RECORD_VOICE_DURATION * 1000L) - currDuration <= 500) {
_showCountDownLiveData.value = (currDuration / 1000).toInt() + 1
} else {
_showCountDownLiveData.value = (currDuration / 1000).toInt() _showCountDownLiveData.value = (currDuration / 1000).toInt()
} }
}
override fun onCompletion() { override fun onCompletion() {
_refreshPlayStatusLiveData.value = false// 播放完成:停止状态(播放按钮) _refreshPlayStatusLiveData.value = false// 播放完成:停止状态(播放按钮)
@@ -311,8 +313,12 @@ class SoundViewModel : BaseViewModel() {
TAG, TAG,
"duration = $currDuration" "duration = $currDuration"
) )
if ((SoundSignatureActivity.MAX_RECORD_VOICE_DURATION * 1000L) - currDuration <= 500) {
_showCountDownLiveData.value = (currDuration / 1000).toInt() + 1
} else {
_showCountDownLiveData.value = (currDuration / 1000).toInt() _showCountDownLiveData.value = (currDuration / 1000).toInt()
} }
}
override fun onCompletion() { override fun onCompletion() {
_refreshPlayStatusLiveData.value = false// 播放完成:停止状态(播放按钮) _refreshPlayStatusLiveData.value = false// 播放完成:停止状态(播放按钮)

View File

@@ -148,9 +148,9 @@ public class RoundProgressView extends View {
canvas.drawArc(oval, -90, ((float)mProgress / mTotalProgress) * 360, false, mRingPaint); // canvas.drawArc(oval, -90, ((float)mProgress / mTotalProgress) * 360, false, mRingPaint); //
//字体 //字体
String txt = mProgress + "%"; // String txt = mProgress + "%";
mTxtWidth = mTextPaint.measureText(txt, 0, txt.length()); // mTxtWidth = mTextPaint.measureText(txt, 0, txt.length());
canvas.drawText(txt, mXCenter - mTxtWidth / 2, mYCenter + mTxtHeight / 4, mTextPaint); // canvas.drawText(txt, mXCenter - mTxtWidth / 2, mYCenter + mTxtHeight / 4, mTextPaint);
} }
} }
public void setText(String string){ public void setText(String string){