[BugFix]声音签名判断房间是否要静音
This commit is contained in:
@@ -121,8 +121,7 @@ class SoundSignatureActivity : BaseViewBindingActivity<ActivitySoundSignatureBin
|
||||
|
||||
private fun initModel() {
|
||||
soundViewModel.showConfirmLiveData.observe(this) {
|
||||
if(AvRoomDataManager.get().isOnMic(AuthModel.get().currentUid.toString())
|
||||
) {
|
||||
if(AvRoomDataManager.get().isOwnerOnMic) {
|
||||
toast(getString(R.string.on_the_mic_not_record))
|
||||
} else {
|
||||
soundViewModel.showRecordingState()
|
||||
|
@@ -11,7 +11,10 @@ import com.yizhuan.erban.audio.SoundSignatureActivity
|
||||
import com.yizhuan.erban.audio.helper.AudioPlayerHelper
|
||||
import com.yizhuan.erban.audio.helper.OnPlayListener
|
||||
import com.yizhuan.erban.base.BaseViewModel
|
||||
import com.yizhuan.xchat_android_core.Constants
|
||||
import com.yizhuan.xchat_android_core.audio.AudioPlayAndRecordManager
|
||||
import com.yizhuan.xchat_android_core.auth.AuthModel
|
||||
import com.yizhuan.xchat_android_core.manager.AudioEngineManager
|
||||
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager
|
||||
import com.yizhuan.xchat_android_core.sound.model.SoundModel
|
||||
import com.yizhuan.xchat_android_core.utils.toast
|
||||
@@ -44,6 +47,9 @@ class SoundViewModel : BaseViewModel() {
|
||||
var audioDur = 0
|
||||
var audioUrl: String? = null
|
||||
|
||||
private var isRemoteMute = false //是否静音
|
||||
private var isMute = false //是否开麦
|
||||
|
||||
private val _showConfirmLiveData = MutableLiveData<String?>()
|
||||
val showConfirmLiveData: MutableLiveData<String?> = _showConfirmLiveData
|
||||
|
||||
@@ -84,6 +90,14 @@ class SoundViewModel : BaseViewModel() {
|
||||
val showRecordConfirmDialogLiveData: MutableLiveData<String?> = _showRecordConfirmDialogLiveData
|
||||
|
||||
init {
|
||||
if (AvRoomDataManager.get().mCurrentRoomInfo != null) {
|
||||
val roomQueueInfo = AvRoomDataManager.get()
|
||||
.getRoomQueueMemberInfoByAccount(AuthModel.get().currentUid.toString())
|
||||
if (roomQueueInfo?.mRoomMicInfo != null) {
|
||||
isMute = AudioEngineManager.get().isMute
|
||||
}
|
||||
isRemoteMute = AudioEngineManager.get().isRemoteMute
|
||||
}
|
||||
audioManager = AudioPlayAndRecordManager.getInstance()
|
||||
}
|
||||
|
||||
@@ -182,6 +196,7 @@ class SoundViewModel : BaseViewModel() {
|
||||
fun showNormalState() {
|
||||
// 正在播放:停止播放
|
||||
AudioPlayerHelper.get().endPlay()
|
||||
openRoomSound()
|
||||
audioState = STATE_RECORD_NORMAL
|
||||
audioUrl = null
|
||||
audioDur = 0
|
||||
@@ -225,6 +240,7 @@ class SoundViewModel : BaseViewModel() {
|
||||
}
|
||||
// 正在播放:停止播放
|
||||
AudioPlayerHelper.get().onPause()
|
||||
openRoomSound()
|
||||
if (audioState != STATE_RECORD_NORMAL) {
|
||||
_refreshPlayStatusLiveData.value = false // onPause() 停止播放并显示停止状态(播放按钮)
|
||||
}
|
||||
@@ -248,6 +264,7 @@ class SoundViewModel : BaseViewModel() {
|
||||
}
|
||||
if (AudioPlayerHelper.get().isPlaying) {
|
||||
AudioPlayerHelper.get().endPlay()
|
||||
openRoomSound()
|
||||
_refreshPlayStatusLiveData.value = false // 返回页面时,此时正在播放声音,则停止播放并显示停止状态(播放按钮)
|
||||
}
|
||||
if (audioState == STATE_RECORD_SUCCESS) { // 已经录制未保存:未保存提示(确定则返回页面/取消则保留当前页面)
|
||||
@@ -264,12 +281,15 @@ class SoundViewModel : BaseViewModel() {
|
||||
if (audioState == STATE_RECORD_SUCCESS || audioState == STATE_RECORD_SAVE_SUCCESS || audioState == STATE_RECORD_AUDIT_SUCCESS) {
|
||||
if (AudioPlayerHelper.get().isPlaying) {
|
||||
AudioPlayerHelper.get().pausePlay()
|
||||
openRoomSound()
|
||||
_refreshPlayStatusLiveData.value = false// 点击试听按钮此时正在播放声音,则暂停播放并显示停止状态(播放按钮)
|
||||
} else if (AudioPlayerHelper.get().isPause) {
|
||||
AudioPlayerHelper.get().continuePlay()
|
||||
stopRoomSound()
|
||||
_refreshPlayStatusLiveData.value = true// 点击试听按钮此时正在暂停声音,则继续播放并显示播放状态(停止按钮)
|
||||
} else if (AudioPlayerHelper.get().isPreparing) {
|
||||
AudioPlayerHelper.get().endPlay()
|
||||
openRoomSound()
|
||||
_refreshPlayStatusLiveData.value = false// 点击试听按钮此时正在准备状态,则停止播放并显示停止状态(播放按钮)
|
||||
} else {
|
||||
if (null != audioFile && audioFile?.exists() == true) {
|
||||
@@ -293,6 +313,7 @@ class SoundViewModel : BaseViewModel() {
|
||||
}
|
||||
|
||||
override fun onPrepared() {
|
||||
stopRoomSound()
|
||||
_refreshPlayStatusLiveData.value = true// 准备完毕要开始播放:播放状态(暂停按钮)
|
||||
}
|
||||
|
||||
@@ -305,6 +326,7 @@ class SoundViewModel : BaseViewModel() {
|
||||
}
|
||||
|
||||
override fun onCompletion() {
|
||||
openRoomSound()
|
||||
_refreshPlayStatusLiveData.value = false// 播放完成:停止状态(播放按钮)
|
||||
_resetStatusLiveData.value = null
|
||||
}
|
||||
@@ -312,6 +334,23 @@ class SoundViewModel : BaseViewModel() {
|
||||
_refreshPlayStatusLiveData.value = true// 点击试听按钮此时并没有正在播放声音,则播放声音并显示正在播放状态(暂停按钮)
|
||||
}
|
||||
|
||||
private fun stopRoomSound() {
|
||||
if (AvRoomDataManager.get().mCurrentRoomInfo != null) {
|
||||
AudioEngineManager.get().isRemoteMute = true //設置靜音
|
||||
AudioEngineManager.get().isMute = true //不能説話
|
||||
AudioEngineManager.get().setRole(Constants.CLIENT_ROLE_AUDIENCE)
|
||||
}
|
||||
}
|
||||
|
||||
private fun openRoomSound() {
|
||||
if (AvRoomDataManager.get().mCurrentRoomInfo != null) {
|
||||
AudioEngineManager.get().isRemoteMute = isRemoteMute //非靜音
|
||||
AudioEngineManager.get().isMute = isMute //能説話
|
||||
AudioEngineManager.get()
|
||||
.setRole(if (isMute) Constants.CLIENT_ROLE_AUDIENCE else Constants.CLIENT_ROLE_BROADCASTER)
|
||||
}
|
||||
}
|
||||
|
||||
fun saveRecord(audioUrl: String, second: Int = audioDur) {
|
||||
this.audioUrl = audioUrl
|
||||
safeLaunch(
|
||||
|
@@ -1,5 +1,7 @@
|
||||
package com.yizhuan.erban.ui.user;
|
||||
|
||||
import static com.yizhuan.erban.ui.user.UserInfoActivity.IdentityState.OWN;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
@@ -64,6 +66,7 @@ import com.yizhuan.erban.vip.VipHelper;
|
||||
import com.yizhuan.xchat_android_constants.XChatConstants;
|
||||
import com.yizhuan.xchat_android_core.Constants;
|
||||
import com.yizhuan.xchat_android_core.auth.AuthModel;
|
||||
import com.yizhuan.xchat_android_core.bean.RoomQueueInfo;
|
||||
import com.yizhuan.xchat_android_core.im.friend.IMFriendModel;
|
||||
import com.yizhuan.xchat_android_core.level.UserLevelVo;
|
||||
import com.yizhuan.xchat_android_core.manager.AudioEngineManager;
|
||||
@@ -71,7 +74,6 @@ import com.yizhuan.xchat_android_core.manager.AvRoomDataManager;
|
||||
import com.yizhuan.xchat_android_core.praise.PraiseModel;
|
||||
import com.yizhuan.xchat_android_core.praise.event.IsLikedEvent;
|
||||
import com.yizhuan.xchat_android_core.praise.event.PraiseEvent;
|
||||
import com.yizhuan.xchat_android_core.room.bean.RoomInfo;
|
||||
import com.yizhuan.xchat_android_core.statistic.StatisticManager;
|
||||
import com.yizhuan.xchat_android_core.statistic.protocol.StatisticsProtocol;
|
||||
import com.yizhuan.xchat_android_core.user.UserInfoUiMgr;
|
||||
@@ -97,10 +99,6 @@ import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.val;
|
||||
|
||||
import static com.yizhuan.erban.ui.user.UserInfoActivity.IdentityState.OWN;
|
||||
|
||||
/**
|
||||
* create by lvzebiao on 2018/8/31
|
||||
*/
|
||||
@@ -129,6 +127,9 @@ public class UserInfoActivity extends BaseBindingActivity<ActivityUserInfoBindin
|
||||
|
||||
private boolean audioPlaying = false;
|
||||
|
||||
private boolean isRemoteMute = false;//是否静音
|
||||
private boolean isMute = false;//是否开麦
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
@Override
|
||||
protected void init() {
|
||||
@@ -163,6 +164,15 @@ public class UserInfoActivity extends BaseBindingActivity<ActivityUserInfoBindin
|
||||
}
|
||||
|
||||
private void initAttentionView() {
|
||||
if (AvRoomDataManager.get().mCurrentRoomInfo != null) {
|
||||
RoomQueueInfo roomQueueInfo = AvRoomDataManager.get()
|
||||
.getRoomQueueMemberInfoByAccount(String.valueOf(AuthModel.get().getCurrentUid()));
|
||||
if (roomQueueInfo != null && roomQueueInfo.mRoomMicInfo != null) {
|
||||
isMute = AudioEngineManager.get().isMute();
|
||||
}
|
||||
isRemoteMute = AudioEngineManager.get().isRemoteMute();
|
||||
}
|
||||
|
||||
if (AuthModel.get().getCurrentUid() == userId) {
|
||||
identityState = OWN;
|
||||
mBinding.tvFansCount.setOnClickListener(this);
|
||||
@@ -315,14 +325,6 @@ public class UserInfoActivity extends BaseBindingActivity<ActivityUserInfoBindin
|
||||
//设置签名
|
||||
UserInfoUiMgr.get().setValue(userInfo);
|
||||
mBinding.tvDesc.setText(userInfo.getUserDesc() != null ? userInfo.getUserDesc() : getResources().getString(R.string.msg_no_user_desc));
|
||||
//设置星座
|
||||
String star = StarUtils.getConstellation(new Date(userInfo.getBirth()));
|
||||
if (null == star) {
|
||||
mBinding.tvConstellation.setVisibility(View.GONE);
|
||||
} else {
|
||||
mBinding.tvConstellation.setText(star);
|
||||
mBinding.tvConstellation.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
//设置性别
|
||||
Drawable drawable = ContextCompat.getDrawable(this,
|
||||
@@ -674,7 +676,7 @@ public class UserInfoActivity extends BaseBindingActivity<ActivityUserInfoBindin
|
||||
playSvgaBg(mBinding.livUser, "svga/user_sound_play.svga");
|
||||
mBinding.ivAudioControl.setImageResource(R.drawable.ic_skill_play);
|
||||
startCountDown(second);
|
||||
if(AvRoomDataManager.get().mCurrentRoomInfo != null){
|
||||
if (AvRoomDataManager.get().mCurrentRoomInfo != null) {
|
||||
AudioEngineManager.get().setRemoteMute(true);//設置靜音
|
||||
AudioEngineManager.get().setMute(true);//不能説話
|
||||
AudioEngineManager.get().setRole(Constants.CLIENT_ROLE_AUDIENCE);
|
||||
@@ -733,10 +735,10 @@ public class UserInfoActivity extends BaseBindingActivity<ActivityUserInfoBindin
|
||||
mBinding.livUser.stopAnimation();
|
||||
mBinding.ivAudioControl.setImageResource(R.drawable.ic_skill_pause);
|
||||
AudioPlayerHelper.get().endPlay();
|
||||
if(AvRoomDataManager.get().mCurrentRoomInfo != null){
|
||||
AudioEngineManager.get().setRemoteMute(false);//非靜音
|
||||
AudioEngineManager.get().setMute(false);//能説話
|
||||
AudioEngineManager.get().setRole(Constants.CLIENT_ROLE_BROADCASTER);
|
||||
if (AvRoomDataManager.get().mCurrentRoomInfo != null) {
|
||||
AudioEngineManager.get().setRemoteMute(isRemoteMute);//非靜音
|
||||
AudioEngineManager.get().setMute(isMute);//能説話
|
||||
AudioEngineManager.get().setRole(isMute ? Constants.CLIENT_ROLE_AUDIENCE : Constants.CLIENT_ROLE_BROADCASTER);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -307,21 +307,6 @@
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_constellation"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/dp_13"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginStart="5dp"
|
||||
android:background="@drawable/shape_58559d"
|
||||
android:gravity="center"
|
||||
android:includeFontPadding="false"
|
||||
android:paddingLeft="6dp"
|
||||
android:paddingRight="6dp"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="@dimen/sp_10"
|
||||
tools:text="@string/layout_activity_user_info_03" />
|
||||
|
||||
<View
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
|
Reference in New Issue
Block a user