fix[声望升级-修复BUG]
This commit is contained in:
@@ -94,7 +94,7 @@ public class LiveFloatView implements Function1<FloatCallbacks.Builder, Unit> {
|
||||
swAuManager.initRtcEngine( mContext);
|
||||
swAuManager.setupRemoteVideo(Integer.parseInt(mLiveBean.getUid()));
|
||||
//进入主播房间
|
||||
swAuManager.joinRoom(CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, SWAuManager.getChannelName(mLiveBean.getUid()));
|
||||
swAuManager.joinRoom(CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken,mLiveBean.getUid(), SWAuManager.getChannelName(mLiveBean.getUid()));
|
||||
}else{
|
||||
videoView = magnetView.findViewById(R.id.video_view);
|
||||
mPlayer = new TXLivePlayer(mContext);
|
||||
@@ -145,7 +145,7 @@ public class LiveFloatView implements Function1<FloatCallbacks.Builder, Unit> {
|
||||
});
|
||||
if(mLiveSDK == Constants.LIVE_SDK_SW){
|
||||
ViewClicksAntiShake.clicksAntiShake(videoFrameLayout, () -> {
|
||||
mPlayer.stopPlay(true);
|
||||
SWAuManager.get().exitChannelAll();
|
||||
APPEasyFloat.getInstance().dismiss(mContext);
|
||||
new Handler().post(liveCheck);
|
||||
});
|
||||
@@ -166,8 +166,13 @@ public class LiveFloatView implements Function1<FloatCallbacks.Builder, Unit> {
|
||||
|
||||
@Override
|
||||
public void dismiss() {
|
||||
if (mPlayer != null)
|
||||
mPlayer.stopPlay(true);
|
||||
if(mLiveSDK == Constants.LIVE_SDK_SW){
|
||||
SWAuManager.get().exitChannelAll();
|
||||
}else{
|
||||
if (mPlayer != null)
|
||||
mPlayer.stopPlay(true);
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
.show(mContext);
|
||||
@@ -192,7 +197,7 @@ public class LiveFloatView implements Function1<FloatCallbacks.Builder, Unit> {
|
||||
public LiveFloatView cacheLiveData(LiveBean mLiveBean, int mLiveType, int mLiveSDK, int mLiveTypeVal) {
|
||||
this.mLiveBean = mLiveBean;
|
||||
this.mLiveType = mLiveType;
|
||||
this.mLiveSDK = Constants.LIVE_SDK_SW;
|
||||
this.mLiveSDK = mLiveSDK;
|
||||
this.mLiveTypeVal = mLiveTypeVal;
|
||||
return instance;
|
||||
}
|
||||
@@ -249,7 +254,7 @@ public class LiveFloatView implements Function1<FloatCallbacks.Builder, Unit> {
|
||||
swAuManager.initRtcEngine( mContext);
|
||||
swAuManager.setupRemoteVideo(Integer.parseInt(mLiveBean.getUid()));
|
||||
//进入主播房间
|
||||
swAuManager.joinRoom(CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, SWAuManager.getChannelName(mLiveBean.getUid()));
|
||||
swAuManager.joinRoom(CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, mLiveBean.getUid(),SWAuManager.getChannelName(mLiveBean.getUid()));
|
||||
}else{
|
||||
TXCloudVideoView videoView = view.findViewById(R.id.video_view);
|
||||
mPlayer = new TXLivePlayer(mContext);
|
||||
|
||||
@@ -2,15 +2,24 @@ package io.agora.beautyapi.faceunity.agora;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.view.SurfaceView;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.CommonAppContext;
|
||||
import com.yunbao.common.bean.BaseModel;
|
||||
import com.yunbao.common.bean.UserBean;
|
||||
import com.yunbao.common.http.API;
|
||||
import com.yunbao.common.http.ResponseModel;
|
||||
import com.yunbao.common.manager.MicUserManager;
|
||||
import com.yunbao.common.manager.MicedUserManager;
|
||||
import com.yunbao.common.manager.base.BaseCacheManager;
|
||||
import com.yunbao.common.manager.imrongcloud.RongcloudIMManager;
|
||||
import com.yunbao.common.utils.L;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
|
||||
import io.agora.rtc2.ChannelMediaOptions;
|
||||
import io.agora.rtc2.Constants;
|
||||
@@ -19,6 +28,15 @@ import io.agora.rtc2.RtcConnection;
|
||||
import io.agora.rtc2.RtcEngineConfig;
|
||||
import io.agora.rtc2.RtcEngineEx;
|
||||
import io.agora.rtc2.video.VideoCanvas;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.functions.Consumer;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import io.rong.imkit.IMCenter;
|
||||
import io.rong.imlib.IRongCallback;
|
||||
import io.rong.imlib.RongIMClient;
|
||||
import io.rong.imlib.model.Conversation;
|
||||
import io.rong.imlib.model.Message;
|
||||
import io.rong.message.TextMessage;
|
||||
|
||||
/**
|
||||
* 声网主播管理类
|
||||
@@ -37,6 +55,14 @@ public class SWAuManager extends BaseCacheManager {
|
||||
private FrameLayout pkContainer3; //pk主播视图3
|
||||
private FrameLayout linkUserContainer;//连麦用户视图
|
||||
|
||||
private int liveMicUid;
|
||||
|
||||
private SwListener swListener;
|
||||
|
||||
public void setSwListener(SwListener swListener) {
|
||||
this.swListener = swListener;
|
||||
}
|
||||
|
||||
public SWAuManager(Context context) {
|
||||
super(context);
|
||||
}
|
||||
@@ -57,13 +83,13 @@ public class SWAuManager extends BaseCacheManager {
|
||||
@Override
|
||||
public void onJoinChannelSuccess(String channel, int uid, int elapsed) {
|
||||
super.onJoinChannelSuccess(channel, uid, elapsed);
|
||||
L.eSw("加入房间成功 channel"+channel+" uid"+uid);
|
||||
L.eSw("加入房间成功 channel" + channel + " uid" + uid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUserJoined(int uid, int elapsed) {
|
||||
super.onUserJoined(uid, elapsed);
|
||||
L.eSw("用户加入房间成功"+uid);
|
||||
L.eSw("用户加入房间成功" + uid);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -84,8 +110,6 @@ public class SWAuManager extends BaseCacheManager {
|
||||
throw new RuntimeException("Check the error.");
|
||||
}
|
||||
mRtcEngine.setChannelProfile(Constants.CHANNEL_PROFILE_LIVE_BROADCASTING); // 直播模式,引擎級別
|
||||
// 启用视频模块
|
||||
mRtcEngine.enableVideo();
|
||||
// 开启本地预览
|
||||
//mRtcEngine.startPreview();
|
||||
}
|
||||
@@ -112,19 +136,20 @@ public class SWAuManager extends BaseCacheManager {
|
||||
|
||||
/**
|
||||
* 创建语音房
|
||||
*
|
||||
* @param token
|
||||
* @param channelName
|
||||
* @param uid
|
||||
*/
|
||||
public void joinAudioRoom(String channelName,String token,int uid){
|
||||
L.eSw("加入房间"+channelName+" uid"+uid);
|
||||
public void joinAudioRoom(String channelName, String token, int uid) {
|
||||
L.eSw("加入房间" + channelName + " uid" + uid);
|
||||
// 直播场景下,设置频道场景为 BROADCASTING (直播场景)
|
||||
mRtcEngine.setChannelProfile(Constants.CHANNEL_PROFILE_LIVE_BROADCASTING);
|
||||
// 创建 ChannelMediaOptions 对象,并进行配置
|
||||
ChannelMediaOptions options = new ChannelMediaOptions();
|
||||
// 根据场景将用户角色设置为 AUDIENCE (观众)
|
||||
options.clientRoleType = Constants.CLIENT_ROLE_AUDIENCE;
|
||||
// 直播场景下,设置频道场景为 BROADCASTING (直播场景)
|
||||
options.audienceLatencyLevel = Constants.CHANNEL_PROFILE_LIVE_BROADCASTING; // 觀眾走極速直播
|
||||
options.autoSubscribeVideo = false;
|
||||
mRtcEngine.disableVideo();
|
||||
options.autoSubscribeAudio = true;
|
||||
mRtcEngine.joinChannel(token, channelName, uid, options);
|
||||
}
|
||||
@@ -148,7 +173,8 @@ public class SWAuManager extends BaseCacheManager {
|
||||
/**
|
||||
* 加入房间
|
||||
*/
|
||||
public void joinRoom(String strUid, String token, String channelName) {
|
||||
public void joinRoom(String strUid, String token, String liveUid, String channelName) {
|
||||
liveMicUid = Integer.parseInt(liveUid);
|
||||
int uid;
|
||||
if (StringUtil.isEmpty(strUid)) {
|
||||
uid = 0;
|
||||
@@ -159,6 +185,13 @@ public class SWAuManager extends BaseCacheManager {
|
||||
SurfaceView surfaceView = new SurfaceView(mContext);
|
||||
audienceContainer.addView(surfaceView);
|
||||
|
||||
// 启用视频模块
|
||||
mRtcEngine.enableVideo();
|
||||
|
||||
//走媒体音量,和音质有关
|
||||
mRtcEngine.setAudioProfile(Constants.AUDIO_PROFILE_MUSIC_HIGH_QUALITY);
|
||||
mRtcEngine.setAudioScenario(Constants.AUDIO_SCENARIO_GAME_STREAMING);
|
||||
|
||||
// 创建 ChannelMediaOptions 对象,并进行配置
|
||||
ChannelMediaOptions options = new ChannelMediaOptions();
|
||||
// 根据场景将用户角色设置为 AUDIENCE (观众)
|
||||
@@ -229,10 +262,11 @@ public class SWAuManager extends BaseCacheManager {
|
||||
mRtcEngine.updateChannelMediaOptions(options);
|
||||
}
|
||||
|
||||
public void setMicAudio(int toUid,boolean isEn) {
|
||||
L.eSw("setMicAudio:toUid" +toUid+"isEn "+ isEn);
|
||||
mRtcEngine.muteRemoteAudioStream(toUid,isEn);
|
||||
public void setMicAudio(int toUid, boolean isEn) {
|
||||
L.eSw("setMicAudio:toUid" + toUid + "isEn " + isEn);
|
||||
mRtcEngine.muteRemoteAudioStream(toUid, isEn);
|
||||
}
|
||||
|
||||
/**
|
||||
* PK-加入对方主播直播间
|
||||
*
|
||||
@@ -310,7 +344,7 @@ public class SWAuManager extends BaseCacheManager {
|
||||
*/
|
||||
public void exitChannelAll() {
|
||||
L.eSw("exitChannelAll exitChannelAll exitChannelAll");
|
||||
if(mRtcEngine!=null){
|
||||
if (mRtcEngine != null) {
|
||||
mRtcEngine.leaveChannel();
|
||||
}
|
||||
}
|
||||
@@ -336,6 +370,17 @@ public class SWAuManager extends BaseCacheManager {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUserOffline(int uid, int reason) {
|
||||
super.onUserOffline(uid, reason);
|
||||
L.eSw("onUserOffline: uid " + uid + " reason" + reason);
|
||||
if (liveMicUid == uid) {
|
||||
if (swListener != null) {
|
||||
swListener.onUserOffline(liveMicUid);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//设置对方主播视图
|
||||
@@ -367,4 +412,7 @@ public class SWAuManager extends BaseCacheManager {
|
||||
this.linkUserContainer = linkUserContainer;
|
||||
}
|
||||
|
||||
public interface SwListener {
|
||||
void onUserOffline(int liveUid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ public class SWManager extends BaseCacheManager {
|
||||
cfg.dimensions = VideoEncoderConfiguration.VD_1920x1080;
|
||||
break;
|
||||
}
|
||||
cfg.frameRate = 24;
|
||||
cfg.frameRate = 20;
|
||||
cfg.bitrate = 0;
|
||||
cfg.mirrorMode = VideoEncoderConfiguration.MIRROR_MODE_TYPE.MIRROR_MODE_ENABLED; //镜像
|
||||
mRtcEngine.setVideoEncoderConfiguration(cfg);
|
||||
@@ -148,7 +148,10 @@ public class SWManager extends BaseCacheManager {
|
||||
|
||||
/**
|
||||
* 设置清晰度
|
||||
*
|
||||
* 单人直播:720x1280
|
||||
* 2人连麦PK:360x640
|
||||
* 3人连麦PK:左侧主播 360x640,右侧两个主播 360x320
|
||||
* 4人连麦PK:360X320
|
||||
* @param selectClarity
|
||||
*/
|
||||
public void setDimensions(int selectClarity) {
|
||||
@@ -221,6 +224,10 @@ public class SWManager extends BaseCacheManager {
|
||||
ChannelMediaOptions options = new ChannelMediaOptions();
|
||||
// 设置角色 BROADCASTER (主播) 或 AUDIENCE (观众)
|
||||
options.clientRoleType = Constants.CLIENT_ROLE_BROADCASTER;
|
||||
|
||||
mRtcEngine.setAudioProfile(Constants.AUDIO_PROFILE_MUSIC_HIGH_QUALITY);
|
||||
mRtcEngine.setAudioScenario(Constants.AUDIO_SCENARIO_GAME_STREAMING);
|
||||
|
||||
// 加入频道
|
||||
mRtcEngine.joinChannel(token, channelName, uid, options);
|
||||
}
|
||||
@@ -297,6 +304,12 @@ public class SWManager extends BaseCacheManager {
|
||||
super.onError(err);
|
||||
L.eSw("onError:" + err);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onVideoSizeChanged(Constants.VideoSourceType source, int uid, int width, int height, int rotation) {
|
||||
super.onVideoSizeChanged(source, uid, width, height, rotation);
|
||||
L.eSw("uid:"+uid+"\nwidth:"+width+"\nheight:"+height);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user