[BugFix]解决试听声音只能到59秒的bug
This commit is contained in:
@@ -409,7 +409,7 @@ class SoundSignatureActivity : BaseViewBindingActivity<ActivitySoundSignatureBin
|
||||
}
|
||||
}
|
||||
|
||||
private fun stopSvga(){
|
||||
private fun stopSvga() {
|
||||
binding.svgRecorder.stopAnimation()
|
||||
binding.svgRecorder.clear()
|
||||
}
|
||||
|
@@ -19,7 +19,7 @@ import lombok.Getter;
|
||||
*/
|
||||
public class AudioPlayerHelper {
|
||||
|
||||
private final static long mIntervalTime = 500L;
|
||||
private final static long mIntervalTime = 100L;
|
||||
|
||||
public interface WHAT_STATUS {
|
||||
int ERROR = 1;
|
||||
|
@@ -10,7 +10,6 @@ import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.audio.SoundSignatureActivity
|
||||
import com.yizhuan.erban.audio.helper.AudioPlayerHelper
|
||||
import com.yizhuan.erban.audio.helper.OnPlayListener
|
||||
import com.yizhuan.erban.audio.presenter.RecordingVoicePresenter
|
||||
import com.yizhuan.erban.base.BaseViewModel
|
||||
import com.yizhuan.xchat_android_core.audio.AudioPlayAndRecordManager
|
||||
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.log.MLog
|
||||
import java.io.File
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
/**
|
||||
* @author wushaocheng
|
||||
@@ -135,7 +133,7 @@ class SoundViewModel : BaseViewModel() {
|
||||
recordType: RecordType
|
||||
) {
|
||||
val dura = audioLength.toDouble() / 1000
|
||||
audioDur = dura.roundToInt()
|
||||
audioDur = dura.toInt()
|
||||
audioFile = file
|
||||
Log.d(
|
||||
TAG, "onRecordSuccess : " + file.path
|
||||
@@ -224,7 +222,7 @@ class SoundViewModel : BaseViewModel() {
|
||||
}
|
||||
// 正在播放:停止播放
|
||||
AudioPlayerHelper.get().onPause()
|
||||
if(audioState != STATE_RECORD_NORMAL) {
|
||||
if (audioState != STATE_RECORD_NORMAL) {
|
||||
_refreshPlayStatusLiveData.value = false // onPause() 停止播放并显示停止状态(播放按钮)
|
||||
}
|
||||
}
|
||||
@@ -287,15 +285,19 @@ class SoundViewModel : BaseViewModel() {
|
||||
TAG,
|
||||
"duration = $currDuration"
|
||||
)
|
||||
if ((SoundSignatureActivity.MAX_RECORD_VOICE_DURATION * 1000L) - currDuration <= 500) {
|
||||
_showCountDownLiveData.value = (currDuration / 1000).toInt() + 1
|
||||
} else {
|
||||
_showCountDownLiveData.value = (currDuration / 1000).toInt()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCompletion() {
|
||||
_refreshPlayStatusLiveData.value = false// 播放完成:停止状态(播放按钮)
|
||||
}
|
||||
})
|
||||
_refreshPlayStatusLiveData.value = true// 点击试听按钮此时并没有正在播放声音,则播放声音并显示正在播放状态(暂停按钮)
|
||||
}else if(null != audioUrl && audioUrl?.contains("http") == true){
|
||||
} else if (null != audioUrl && audioUrl?.contains("http") == true) {
|
||||
MLog.debug(TAG, "play audioUrl: $audioUrl")
|
||||
AudioPlayerHelper.get().playInThread(audioUrl, object : OnPlayListener {
|
||||
override fun onError(error: String) {
|
||||
@@ -311,8 +313,12 @@ class SoundViewModel : BaseViewModel() {
|
||||
TAG,
|
||||
"duration = $currDuration"
|
||||
)
|
||||
if ((SoundSignatureActivity.MAX_RECORD_VOICE_DURATION * 1000L) - currDuration <= 500) {
|
||||
_showCountDownLiveData.value = (currDuration / 1000).toInt() + 1
|
||||
} else {
|
||||
_showCountDownLiveData.value = (currDuration / 1000).toInt()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCompletion() {
|
||||
_refreshPlayStatusLiveData.value = false// 播放完成:停止状态(播放按钮)
|
||||
|
@@ -148,9 +148,9 @@ public class RoundProgressView extends View {
|
||||
canvas.drawArc(oval, -90, ((float)mProgress / mTotalProgress) * 360, false, mRingPaint); //
|
||||
|
||||
//字体
|
||||
String txt = mProgress + "%";
|
||||
mTxtWidth = mTextPaint.measureText(txt, 0, txt.length());
|
||||
canvas.drawText(txt, mXCenter - mTxtWidth / 2, mYCenter + mTxtHeight / 4, mTextPaint);
|
||||
// String txt = mProgress + "%";
|
||||
// mTxtWidth = mTextPaint.measureText(txt, 0, txt.length());
|
||||
// canvas.drawText(txt, mXCenter - mTxtWidth / 2, mYCenter + mTxtHeight / 4, mTextPaint);
|
||||
}
|
||||
}
|
||||
public void setText(String string){
|
||||
|
Reference in New Issue
Block a user