add[声望升级]
This commit is contained in:
parent
a100ab1a4a
commit
5922f4c08b
2
app/proguard-rules.pro
vendored
2
app/proguard-rules.pro
vendored
@ -292,3 +292,5 @@ rx.internal.util.atomic.LinkedQueueNode* consumerNode;
|
|||||||
|
|
||||||
-keep class com.shayu.lib_google.**{*;}
|
-keep class com.shayu.lib_google.**{*;}
|
||||||
-keep class com.shayu.lib_huawei.**{*;}
|
-keep class com.shayu.lib_huawei.**{*;}
|
||||||
|
|
||||||
|
-keep class io.agora.**{*;}
|
||||||
|
@ -89,6 +89,11 @@
|
|||||||
<!-- <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />-->
|
<!-- <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />-->
|
||||||
<!-- <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />-->
|
<!-- <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />-->
|
||||||
<uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY" />
|
<uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY" />
|
||||||
|
|
||||||
|
<!-- 声网新增 -->
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
|
||||||
|
<uses-permission android:name="android.permission.BLUETOOTH_SCAN"/>
|
||||||
|
|
||||||
<queries>
|
<queries>
|
||||||
<package android:name="com.twitter.android" />
|
<package android:name="com.twitter.android" />
|
||||||
<package android:name="jp.naver.line.android" />
|
<package android:name="jp.naver.line.android" />
|
||||||
|
@ -225,6 +225,7 @@ dependencies {
|
|||||||
api 'com.github.FlyJingFish:GradientTextView:1.2.4'
|
api 'com.github.FlyJingFish:GradientTextView:1.2.4'
|
||||||
//轮播 一屏显示多个
|
//轮播 一屏显示多个
|
||||||
api 'com.github.xiaohaibin:XBanner:androidx_v1.2.6'
|
api 'com.github.xiaohaibin:XBanner:androidx_v1.2.6'
|
||||||
|
//声网SDK
|
||||||
|
api 'io.agora.rtc:agora-special-full:4.1.1.28'
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,6 @@ public class CommonAppConfig {
|
|||||||
public static int alert_time = 1;
|
public static int alert_time = 1;
|
||||||
public static int alert_end_time = 1;
|
public static int alert_end_time = 1;
|
||||||
|
|
||||||
|
|
||||||
private CommonAppConfig() {
|
private CommonAppConfig() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
147
common/src/main/java/com/yunbao/common/manager/SWAuManager.java
Normal file
147
common/src/main/java/com/yunbao/common/manager/SWAuManager.java
Normal file
@ -0,0 +1,147 @@
|
|||||||
|
package com.yunbao.common.manager;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.view.SurfaceView;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
|
|
||||||
|
import com.yunbao.common.CommonAppContext;
|
||||||
|
import com.yunbao.common.manager.base.BaseCacheManager;
|
||||||
|
import com.yunbao.common.utils.StringUtil;
|
||||||
|
|
||||||
|
import io.agora.rtc2.ChannelMediaOptions;
|
||||||
|
import io.agora.rtc2.Constants;
|
||||||
|
import io.agora.rtc2.IRtcEngineEventHandler;
|
||||||
|
import io.agora.rtc2.RtcEngine;
|
||||||
|
import io.agora.rtc2.RtcEngineConfig;
|
||||||
|
import io.agora.rtc2.video.VideoCanvas;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 声网主播管理类
|
||||||
|
*/
|
||||||
|
public class SWAuManager extends BaseCacheManager {
|
||||||
|
|
||||||
|
// 填写项目的 App ID,可在声网控制台中生成
|
||||||
|
public static final String shengwang_appId = "4cf0376582d742ac8a96778b25b1079e";
|
||||||
|
// 填写频道名
|
||||||
|
public static final String shengwang_channelName = "12";
|
||||||
|
// 填写声网控制台中生成的临时 Token
|
||||||
|
public static final String shengwang_token = "007eJxSYJi477Xju22xV7ov7GfzzOnbtCU0IuK9+YuwWf2uLPGnl8xRYDBJTjMwNjcztTBKMTcxSky2SLQ0Mze3SDIyTTI0MLdMPWQrltYQyMjw/4kCCyMDBIL4TAyGRiwMlpaWloAAAAD//w/TIFY=";
|
||||||
|
private Activity mContext;
|
||||||
|
public static SWAuManager manager;
|
||||||
|
private RtcEngine mRtcEngine;
|
||||||
|
private FrameLayout audienceContainer; //主播视图
|
||||||
|
private FrameLayout pkContainer1; //pk主播视图1
|
||||||
|
private FrameLayout pkContainer2; //pk主播视图2
|
||||||
|
private FrameLayout pkContainer3; //pk主播视图3
|
||||||
|
private FrameLayout linkUserContainer;//连麦用户视图
|
||||||
|
|
||||||
|
public SWAuManager(Context context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取单列
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static SWAuManager get() {
|
||||||
|
if (null == manager) {
|
||||||
|
manager = new SWAuManager(CommonAppContext.sInstance.getBaseContext());
|
||||||
|
}
|
||||||
|
return manager;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化声网SDK
|
||||||
|
*/
|
||||||
|
public void initRtcEngine(Activity mContext) {
|
||||||
|
this.mContext = mContext;
|
||||||
|
try {
|
||||||
|
// 创建 RtcEngineConfig 对象,并进行配置
|
||||||
|
RtcEngineConfig config = new RtcEngineConfig();
|
||||||
|
config.mContext = mContext;
|
||||||
|
config.mAppId = SWAuManager.shengwang_appId;
|
||||||
|
config.mEventHandler = mRtcEventHandler;
|
||||||
|
// 创建并初始化 RtcEngine
|
||||||
|
mRtcEngine = RtcEngine.create(config);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException("Check the error.");
|
||||||
|
}
|
||||||
|
mRtcEngine.setChannelProfile(Constants.CHANNEL_PROFILE_LIVE_BROADCASTING); // 直播模式,引擎級別
|
||||||
|
// 启用视频模块
|
||||||
|
mRtcEngine.enableVideo();
|
||||||
|
// 开启本地预览
|
||||||
|
//mRtcEngine.startPreview();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* guanzhong
|
||||||
|
* 加入房间
|
||||||
|
*/
|
||||||
|
public void joinRoom(String strUid, String token, String channelName) {
|
||||||
|
int uid;
|
||||||
|
if (StringUtil.isEmpty(strUid)) {
|
||||||
|
uid = 0;
|
||||||
|
} else {
|
||||||
|
uid = Integer.parseInt(strUid);
|
||||||
|
}
|
||||||
|
// 创建一个 SurfaceView 对象,并将其作为 FrameLayout 的子对象
|
||||||
|
SurfaceView surfaceView = new SurfaceView(mContext);
|
||||||
|
audienceContainer.addView(surfaceView);
|
||||||
|
|
||||||
|
// 创建 ChannelMediaOptions 对象,并进行配置
|
||||||
|
ChannelMediaOptions options = new ChannelMediaOptions();
|
||||||
|
// 根据场景将用户角色设置为 AUDIENCE (观众)
|
||||||
|
options.clientRoleType = Constants.CLIENT_ROLE_AUDIENCE;
|
||||||
|
// 直播场景下,设置频道场景为 BROADCASTING (直播场景)
|
||||||
|
options.audienceLatencyLevel = Constants.AUDIENCE_LATENCY_LEVEL_LOW_LATENCY; // 觀眾走極速直播
|
||||||
|
|
||||||
|
// 使用临时 Token 加入频道,自行指定用户 ID 并确保其在频道内的唯一性
|
||||||
|
mRtcEngine.joinChannel(token, channelName, uid, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
//远程监听
|
||||||
|
private final IRtcEngineEventHandler mRtcEventHandler = new IRtcEngineEventHandler() {
|
||||||
|
@Override
|
||||||
|
// 监听频道内的远端用户,获取用户的 uid 信息
|
||||||
|
public void onUserJoined(int uid, int elapsed) {
|
||||||
|
mContext.runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
// 获取 uid 后,设置远端视频视图
|
||||||
|
setupRemoteVideo(uid);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
//设置对方主播视图
|
||||||
|
public void setupRemoteVideo(int uid) {
|
||||||
|
SurfaceView surfaceView = new SurfaceView(mContext);
|
||||||
|
surfaceView.setZOrderMediaOverlay(true);
|
||||||
|
audienceContainer.addView(surfaceView);
|
||||||
|
// 将 SurfaceView 对象传入声网实时互动 SDK,设置远端视图
|
||||||
|
mRtcEngine.setupRemoteVideo(new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_HIDDEN, uid));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAudienceContainer(FrameLayout audienceContainer) {
|
||||||
|
this.audienceContainer = audienceContainer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPkContainer1(FrameLayout pkContainer1) {
|
||||||
|
this.pkContainer1 = pkContainer1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPkContainer2(FrameLayout pkContainer2) {
|
||||||
|
this.pkContainer2 = pkContainer2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPkContainer3(FrameLayout pkContainer3) {
|
||||||
|
this.pkContainer3 = pkContainer3;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLinkUserContainer(FrameLayout linkUserContainer) {
|
||||||
|
this.linkUserContainer = linkUserContainer;
|
||||||
|
}
|
||||||
|
}
|
207
common/src/main/java/com/yunbao/common/manager/SWManager.java
Normal file
207
common/src/main/java/com/yunbao/common/manager/SWManager.java
Normal file
@ -0,0 +1,207 @@
|
|||||||
|
package com.yunbao.common.manager;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.view.SurfaceView;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
|
|
||||||
|
import com.yunbao.common.CommonAppContext;
|
||||||
|
import com.yunbao.common.manager.base.BaseCacheManager;
|
||||||
|
import com.yunbao.common.utils.StringUtil;
|
||||||
|
import com.yunbao.common.utils.ToastUtil;
|
||||||
|
|
||||||
|
import cn.rongcloud.rtc.base.RCRTCParamsType;
|
||||||
|
import io.agora.rtc2.ChannelMediaOptions;
|
||||||
|
import io.agora.rtc2.Constants;
|
||||||
|
import io.agora.rtc2.IRtcEngineEventHandler;
|
||||||
|
import io.agora.rtc2.RtcEngine;
|
||||||
|
import io.agora.rtc2.RtcEngineConfig;
|
||||||
|
import io.agora.rtc2.video.VideoCanvas;
|
||||||
|
import io.agora.rtc2.video.VideoEncoderConfiguration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 声网主播管理类
|
||||||
|
*/
|
||||||
|
public class SWManager extends BaseCacheManager {
|
||||||
|
|
||||||
|
// 填写项目的 App ID,可在声网控制台中生成
|
||||||
|
public static final String shengwang_appId = "4cf0376582d742ac8a96778b25b1079e";
|
||||||
|
// 填写频道名
|
||||||
|
public static final String shengwang_channelName = "12";
|
||||||
|
// 填写声网控制台中生成的临时 Token
|
||||||
|
public static final String shengwang_token = "007eJxTYOD6Iv3buTHm6666BKY1Cr7mUZU3tY0eHH5qbF4jv5nNukqBwSQ5zcDY3MzUwijF3MQoMdki0dLM3Nwiycg0ydDA3DL1xX/RtIZARgb+3ExWRgYIBPGZGAyNGBgAhDMb8Q==";
|
||||||
|
private Activity mContext;
|
||||||
|
public static SWManager manager;
|
||||||
|
private RtcEngine mRtcEngine;
|
||||||
|
private int uid;
|
||||||
|
VideoEncoderConfiguration cfg;
|
||||||
|
private FrameLayout anchorContainer; //主播视图
|
||||||
|
private FrameLayout pkContainer1; //pk主播视图1
|
||||||
|
private FrameLayout pkContainer2; //pk主播视图2
|
||||||
|
private FrameLayout pkContainer3; //pk主播视图3
|
||||||
|
private FrameLayout linkUserContainer;//连麦用户视图
|
||||||
|
private onRtcEngineListener onRtcEngineListener;
|
||||||
|
|
||||||
|
public void setOnRtcEngineListener(SWManager.onRtcEngineListener onRtcEngineListener) {
|
||||||
|
this.onRtcEngineListener = onRtcEngineListener;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SWManager(Context context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取单列
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static SWManager get() {
|
||||||
|
if (null == manager) {
|
||||||
|
manager = new SWManager(CommonAppContext.sInstance.getBaseContext());
|
||||||
|
}
|
||||||
|
return manager;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化声网SDK
|
||||||
|
*/
|
||||||
|
public void initRtcEngine(Activity mContext, String strUid) {
|
||||||
|
this.mContext = mContext;
|
||||||
|
if (StringUtil.isEmpty(strUid)) {
|
||||||
|
uid = 0;
|
||||||
|
} else {
|
||||||
|
uid = Integer.parseInt(strUid);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
// 创建 RtcEngineConfig 对象,并进行配置
|
||||||
|
RtcEngineConfig config = new RtcEngineConfig();
|
||||||
|
config.mContext = mContext;
|
||||||
|
config.mAppId = SWManager.shengwang_appId;
|
||||||
|
config.mEventHandler = mRtcEventHandler;
|
||||||
|
// 创建并初始化 RtcEngine
|
||||||
|
mRtcEngine = RtcEngine.create(config);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException("Check the error.");
|
||||||
|
}
|
||||||
|
mRtcEngine.setChannelProfile(Constants.CHANNEL_PROFILE_LIVE_BROADCASTING);
|
||||||
|
// 启用视频模块
|
||||||
|
mRtcEngine.enableVideo();
|
||||||
|
// 开启本地预览
|
||||||
|
mRtcEngine.startPreview();
|
||||||
|
|
||||||
|
cfg = new VideoEncoderConfiguration();
|
||||||
|
//设置默认分辨率
|
||||||
|
switch (IMLoginManager.get(mContext).getSelectClarity()) {
|
||||||
|
case 0:
|
||||||
|
cfg.dimensions = VideoEncoderConfiguration.VD_840x480;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
cfg.dimensions = VideoEncoderConfiguration.VD_1280x720;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
cfg.dimensions = VideoEncoderConfiguration.VD_1920x1080;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
cfg.frameRate = 24;
|
||||||
|
cfg.bitrate = 0;
|
||||||
|
cfg.mirrorMode = VideoEncoderConfiguration.MIRROR_MODE_TYPE.MIRROR_MODE_ENABLED; //镜像
|
||||||
|
mRtcEngine.setVideoEncoderConfiguration(cfg);
|
||||||
|
|
||||||
|
// 创建一个 SurfaceView 对象,并将其作为 FrameLayout 的子对象
|
||||||
|
SurfaceView surfaceView = new SurfaceView(mContext);
|
||||||
|
anchorContainer.addView(surfaceView);
|
||||||
|
// 设置视图
|
||||||
|
mRtcEngine.setupLocalVideo(new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_HIDDEN, uid));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDimensions(int selectClarity) {
|
||||||
|
if (cfg != null && mRtcEngine != null) {
|
||||||
|
switch (selectClarity) {
|
||||||
|
case 0:
|
||||||
|
cfg.dimensions = VideoEncoderConfiguration.VD_840x480;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
cfg.dimensions = VideoEncoderConfiguration.VD_1280x720;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
cfg.dimensions = VideoEncoderConfiguration.VD_1920x1080;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
mRtcEngine.setVideoEncoderConfiguration(cfg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建房间
|
||||||
|
*/
|
||||||
|
public void createRoom(String token, String channelName) {
|
||||||
|
ChannelMediaOptions options = new ChannelMediaOptions();
|
||||||
|
// 设置角色 BROADCASTER (主播) 或 AUDIENCE (观众)
|
||||||
|
options.clientRoleType = Constants.CLIENT_ROLE_BROADCASTER;
|
||||||
|
// 加入频道
|
||||||
|
mRtcEngine.joinChannel(token, channelName, uid, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
//远程监听
|
||||||
|
private final IRtcEngineEventHandler mRtcEventHandler = new IRtcEngineEventHandler() {
|
||||||
|
@Override
|
||||||
|
// 监听频道内的远端用户,获取用户的 uid 信息
|
||||||
|
public void onUserJoined(int uid, int elapsed) {
|
||||||
|
mContext.runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
// 获取 uid 后,设置远端视频视图
|
||||||
|
setupRemoteVideo(uid);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onJoinChannelSuccess(String channel, int uid, int elapsed) {
|
||||||
|
super.onJoinChannelSuccess(channel, uid, elapsed);
|
||||||
|
if (onRtcEngineListener != null) {
|
||||||
|
onRtcEngineListener.onOpenSuccess(channel, uid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(int err) {
|
||||||
|
super.onError(err);
|
||||||
|
ToastUtil.show("onError:" + err);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
//设置对方主播视图
|
||||||
|
private void setupRemoteVideo(int uid) {
|
||||||
|
SurfaceView surfaceView = new SurfaceView(mContext);
|
||||||
|
surfaceView.setZOrderMediaOverlay(true);
|
||||||
|
pkContainer1.addView(surfaceView);
|
||||||
|
// 将 SurfaceView 对象传入声网实时互动 SDK,设置远端视图
|
||||||
|
mRtcEngine.setupRemoteVideo(new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_FIT, uid));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAnchorContainer(FrameLayout anchorContainer) {
|
||||||
|
this.anchorContainer = anchorContainer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface onRtcEngineListener {
|
||||||
|
void onOpenSuccess(String channel, int uid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPkContainer1(FrameLayout pkContainer1) {
|
||||||
|
this.pkContainer1 = pkContainer1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPkContainer2(FrameLayout pkContainer2) {
|
||||||
|
this.pkContainer2 = pkContainer2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPkContainer3(FrameLayout pkContainer3) {
|
||||||
|
this.pkContainer3 = pkContainer3;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLinkUserContainer(FrameLayout linkUserContainer) {
|
||||||
|
this.linkUserContainer = linkUserContainer;
|
||||||
|
}
|
||||||
|
}
|
@ -124,6 +124,10 @@
|
|||||||
<activity
|
<activity
|
||||||
android:name=".activity.CompensateActivity"
|
android:name=".activity.CompensateActivity"
|
||||||
android:screenOrientation="portrait" />
|
android:screenOrientation="portrait" />
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".activity.NewLiveActivity"
|
||||||
|
android:screenOrientation="portrait" />
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
139
live/src/main/java/com/yunbao/live/activity/NewLiveActivity.java
Normal file
139
live/src/main/java/com/yunbao/live/activity/NewLiveActivity.java
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
package com.yunbao.live.activity;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.core.app.ActivityCompat;
|
||||||
|
import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
|
import android.Manifest;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.view.SurfaceView;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import com.yunbao.common.manager.SWManager;
|
||||||
|
import com.yunbao.live.R;
|
||||||
|
|
||||||
|
import io.agora.rtc2.ChannelMediaOptions;
|
||||||
|
import io.agora.rtc2.Constants;
|
||||||
|
import io.agora.rtc2.IRtcEngineEventHandler;
|
||||||
|
import io.agora.rtc2.RtcEngine;
|
||||||
|
import io.agora.rtc2.RtcEngineConfig;
|
||||||
|
import io.agora.rtc2.video.VideoCanvas;
|
||||||
|
|
||||||
|
|
||||||
|
public class NewLiveActivity extends AppCompatActivity {
|
||||||
|
private RtcEngine mRtcEngine;
|
||||||
|
|
||||||
|
private final IRtcEngineEventHandler mRtcEventHandler = new IRtcEngineEventHandler() {
|
||||||
|
@Override
|
||||||
|
// 监听频道内的远端用户,获取用户的 uid 信息
|
||||||
|
public void onUserJoined(int uid, int elapsed) {
|
||||||
|
runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
// 获取 uid 后,设置远端视频视图
|
||||||
|
setupRemoteVideo(uid);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private void initializeAndJoinChannel() {
|
||||||
|
try {
|
||||||
|
// 创建 RtcEngineConfig 对象,并进行配置
|
||||||
|
RtcEngineConfig config = new RtcEngineConfig();
|
||||||
|
config.mContext = getBaseContext();
|
||||||
|
config.mAppId = SWManager.shengwang_appId;
|
||||||
|
config.mEventHandler = mRtcEventHandler;
|
||||||
|
// 创建并初始化 RtcEngine
|
||||||
|
mRtcEngine = RtcEngine.create(config);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException("Check the error.");
|
||||||
|
}
|
||||||
|
// 启用视频模块
|
||||||
|
mRtcEngine.enableVideo();
|
||||||
|
// 开启本地预览
|
||||||
|
mRtcEngine.startPreview();
|
||||||
|
|
||||||
|
// 创建一个 SurfaceView 对象,并将其作为 FrameLayout 的子对象
|
||||||
|
FrameLayout container = findViewById(R.id.local_video_view_container);
|
||||||
|
SurfaceView surfaceView = new SurfaceView(getBaseContext());
|
||||||
|
container.addView(surfaceView);
|
||||||
|
// 将 SurfaceView 对象传入声网实时互动 SDK,设置本地视图
|
||||||
|
mRtcEngine.setupLocalVideo(new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_FIT, 0));
|
||||||
|
|
||||||
|
// 创建 ChannelMediaOptions 对象,并进行配置
|
||||||
|
ChannelMediaOptions options = new ChannelMediaOptions();
|
||||||
|
// 根据场景将用户角色设置为 BROADCASTER (主播) 或 AUDIENCE (观众)
|
||||||
|
options.clientRoleType = Constants.CLIENT_ROLE_BROADCASTER;
|
||||||
|
// 直播场景下,设置频道场景为 BROADCASTING (直播场景)
|
||||||
|
options.channelProfile = Constants.CHANNEL_PROFILE_LIVE_BROADCASTING;
|
||||||
|
|
||||||
|
// 使用临时 Token 加入频道,自行指定用户 ID 并确保其在频道内的唯一性
|
||||||
|
mRtcEngine.joinChannel(SWManager.shengwang_token, SWManager.shengwang_channelName, 0, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupRemoteVideo(int uid) {
|
||||||
|
FrameLayout container = findViewById(R.id.remote_video_view_container);
|
||||||
|
SurfaceView surfaceView = new SurfaceView(getBaseContext());
|
||||||
|
surfaceView.setZOrderMediaOverlay(true);
|
||||||
|
container.addView(surfaceView);
|
||||||
|
// 将 SurfaceView 对象传入声网实时互动 SDK,设置远端视图
|
||||||
|
mRtcEngine.setupRemoteVideo(new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_FIT, uid));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final int PERMISSION_REQ_ID = 22;
|
||||||
|
|
||||||
|
// 获取体验实时音视频互动所需的录音、摄像头等权限
|
||||||
|
private String[] getRequiredPermissions() {
|
||||||
|
// 判断 targetSDKVersion 31 及以上时所需的权限
|
||||||
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {
|
||||||
|
return new String[]{
|
||||||
|
Manifest.permission.RECORD_AUDIO, // 录音权限
|
||||||
|
Manifest.permission.CAMERA, // 摄像头权限
|
||||||
|
Manifest.permission.READ_PHONE_STATE, // 读取电话状态权限
|
||||||
|
Manifest.permission.BLUETOOTH_CONNECT // 蓝牙连接权限
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return new String[]{
|
||||||
|
Manifest.permission.RECORD_AUDIO,
|
||||||
|
Manifest.permission.CAMERA
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean checkPermissions() {
|
||||||
|
for (String permission : getRequiredPermissions()) {
|
||||||
|
int permissionCheck = ContextCompat.checkSelfPermission(this, permission);
|
||||||
|
if (permissionCheck != PackageManager.PERMISSION_GRANTED) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.acticity_new_live);
|
||||||
|
// 如果已经授权,则初始化 RtcEngine 并加入频道
|
||||||
|
initializeAndJoinChannel();
|
||||||
|
if (checkPermissions()) {
|
||||||
|
initializeAndJoinChannel();
|
||||||
|
} else {
|
||||||
|
ActivityCompat.requestPermissions(this, getRequiredPermissions(), PERMISSION_REQ_ID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
|
||||||
|
// 停止本地视频预览
|
||||||
|
mRtcEngine.stopPreview();
|
||||||
|
|
||||||
|
// 离开频道
|
||||||
|
mRtcEngine.leaveChannel();
|
||||||
|
}
|
||||||
|
}
|
@ -44,6 +44,7 @@ import com.yunbao.common.interfaces.CommonCallback;
|
|||||||
import com.yunbao.common.interfaces.ImageResultCallback;
|
import com.yunbao.common.interfaces.ImageResultCallback;
|
||||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||||
import com.yunbao.common.manager.IMLoginManager;
|
import com.yunbao.common.manager.IMLoginManager;
|
||||||
|
import com.yunbao.common.manager.SWManager;
|
||||||
import com.yunbao.common.utils.Bus;
|
import com.yunbao.common.utils.Bus;
|
||||||
import com.yunbao.common.utils.DialogUitl;
|
import com.yunbao.common.utils.DialogUitl;
|
||||||
import com.yunbao.common.utils.L;
|
import com.yunbao.common.utils.L;
|
||||||
@ -327,7 +328,10 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl
|
|||||||
if (liveOpenCustomPopup != null) {
|
if (liveOpenCustomPopup != null) {
|
||||||
liveOpenCustomPopup.setSelectClarity(selectClarity);
|
liveOpenCustomPopup.setSelectClarity(selectClarity);
|
||||||
}
|
}
|
||||||
//設置開播分辨率
|
SWManager.get().setDimensions(selectClarity);
|
||||||
|
|
||||||
|
|
||||||
|
/*//設置開播分辨率
|
||||||
RCRTCParamsType.RCRTCVideoResolution rcrtcVideoResolution = RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_480_848;
|
RCRTCParamsType.RCRTCVideoResolution rcrtcVideoResolution = RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_480_848;
|
||||||
int minRate = 200;
|
int minRate = 200;
|
||||||
int maxRate = 900;
|
int maxRate = 900;
|
||||||
@ -355,7 +359,7 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl
|
|||||||
.setVideoFps(RCRTCParamsType.RCRTCVideoFps.Fps_15)
|
.setVideoFps(RCRTCParamsType.RCRTCVideoFps.Fps_15)
|
||||||
.setVideoResolution(rcrtcVideoResolution)
|
.setVideoResolution(rcrtcVideoResolution)
|
||||||
.build();
|
.build();
|
||||||
RCRTCEngine.getInstance().getDefaultVideoStream().setVideoConfig(config);
|
RCRTCEngine.getInstance().getDefaultVideoStream().setVideoConfig(config);*/
|
||||||
Log.e("切换分辨率", "时间戳" + System.currentTimeMillis());
|
Log.e("切换分辨率", "时间戳" + System.currentTimeMillis());
|
||||||
//重新发布一下流
|
//重新发布一下流
|
||||||
Bus.get().post(new LivePushRyEvent());
|
Bus.get().post(new LivePushRyEvent());
|
||||||
|
@ -3,6 +3,7 @@ package com.yunbao.live.views;
|
|||||||
import static com.lzy.okgo.utils.HttpUtils.runOnUiThread;
|
import static com.lzy.okgo.utils.HttpUtils.runOnUiThread;
|
||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
|
import android.app.Activity;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
@ -36,6 +37,7 @@ import com.yunbao.common.http.HttpCallback;
|
|||||||
import com.yunbao.common.http.HttpClient;
|
import com.yunbao.common.http.HttpClient;
|
||||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||||
import com.yunbao.common.manager.IMLoginManager;
|
import com.yunbao.common.manager.IMLoginManager;
|
||||||
|
import com.yunbao.common.manager.SWAuManager;
|
||||||
import com.yunbao.common.utils.Bus;
|
import com.yunbao.common.utils.Bus;
|
||||||
import com.yunbao.common.utils.DialogUitl;
|
import com.yunbao.common.utils.DialogUitl;
|
||||||
import com.yunbao.common.utils.DpUtil;
|
import com.yunbao.common.utils.DpUtil;
|
||||||
@ -97,6 +99,8 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
|||||||
private RelativeLayout mPkContainer;
|
private RelativeLayout mPkContainer;
|
||||||
public StyledPlayerView mVideoView;
|
public StyledPlayerView mVideoView;
|
||||||
|
|
||||||
|
private FrameLayout playFrameLayout;
|
||||||
|
|
||||||
private View mLoading, mLoading2;
|
private View mLoading, mLoading2;
|
||||||
private ImageView mCover;
|
private ImageView mCover;
|
||||||
private boolean mPaused;//是否切后台了
|
private boolean mPaused;//是否切后台了
|
||||||
@ -122,6 +126,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
|||||||
//0未申请1申请中2连麦中
|
//0未申请1申请中2连麦中
|
||||||
RCRTCRoom rcrtcRoom;
|
RCRTCRoom rcrtcRoom;
|
||||||
String purl, srcUrl;
|
String purl, srcUrl;
|
||||||
|
SWAuManager swAuManager;
|
||||||
|
|
||||||
public int getLandscape() {
|
public int getLandscape() {
|
||||||
return landscape;
|
return landscape;
|
||||||
@ -146,6 +151,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
|||||||
EventBus.getDefault().register(this);
|
EventBus.getDefault().register(this);
|
||||||
Bus.getOn(this);
|
Bus.getOn(this);
|
||||||
mRoot = (ViewGroup) findViewById(R.id.root);
|
mRoot = (ViewGroup) findViewById(R.id.root);
|
||||||
|
playFrameLayout = (FrameLayout) findViewById(R.id.playView);
|
||||||
mSmallContainer = (ViewGroup) findViewById(R.id.small_container);
|
mSmallContainer = (ViewGroup) findViewById(R.id.small_container);
|
||||||
mLeftContainer = (ViewGroup) findViewById(R.id.left_container);
|
mLeftContainer = (ViewGroup) findViewById(R.id.left_container);
|
||||||
mRightContainer = (ViewGroup) findViewById(R.id.right_container);
|
mRightContainer = (ViewGroup) findViewById(R.id.right_container);
|
||||||
@ -167,6 +173,13 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
|
|||||||
mPlayer = new LiveExoPlayerManager(mContext);
|
mPlayer = new LiveExoPlayerManager(mContext);
|
||||||
mPlayer.setMainView(mVideoView);
|
mPlayer.setMainView(mVideoView);
|
||||||
mPlayer.setListener(new ExoPlayerListener());
|
mPlayer.setListener(new ExoPlayerListener());
|
||||||
|
|
||||||
|
swAuManager = SWAuManager.get();
|
||||||
|
swAuManager.setAudienceContainer(playFrameLayout);
|
||||||
|
swAuManager.initRtcEngine((Activity) mContext);
|
||||||
|
swAuManager.setupRemoteVideo(11);
|
||||||
|
swAuManager.joinRoom("9999", SWAuManager.shengwang_token, SWAuManager.shengwang_channelName);
|
||||||
|
|
||||||
debugView = new TextView(mContext);
|
debugView = new TextView(mContext);
|
||||||
debugView.setBackgroundColor(Color.WHITE);
|
debugView.setBackgroundColor(Color.WHITE);
|
||||||
|
|
||||||
|
1374
live/src/main/java/com/yunbao/live/views/LivePlaySwViewHolder.java
Normal file
1374
live/src/main/java/com/yunbao/live/views/LivePlaySwViewHolder.java
Normal file
File diff suppressed because it is too large
Load Diff
@ -9,8 +9,8 @@ import static com.yunbao.live.event.LiveAudienceEvent.LiveAudienceType.LIVE_PK_I
|
|||||||
import static com.yunbao.live.presenter.LiveRyLinkMicPkPresenter.inputStreamList;
|
import static com.yunbao.live.presenter.LiveRyLinkMicPkPresenter.inputStreamList;
|
||||||
import static com.yunbao.live.presenter.LiveRyLinkMicPkPresenter.inputStreamList1;
|
import static com.yunbao.live.presenter.LiveRyLinkMicPkPresenter.inputStreamList1;
|
||||||
import static com.yunbao.live.presenter.LiveRyLinkMicPkPresenter.mPkUid;
|
import static com.yunbao.live.presenter.LiveRyLinkMicPkPresenter.mPkUid;
|
||||||
import static cn.rongcloud.rtc.base.RCRTCLiveRole.BROADCASTER;
|
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
@ -46,6 +46,7 @@ import com.yunbao.common.http.live.LiveNetManager;
|
|||||||
import com.yunbao.common.manager.IMLoginManager;
|
import com.yunbao.common.manager.IMLoginManager;
|
||||||
import com.yunbao.common.manager.IMRTCManager;
|
import com.yunbao.common.manager.IMRTCManager;
|
||||||
import com.yunbao.common.manager.RandomPkManager;
|
import com.yunbao.common.manager.RandomPkManager;
|
||||||
|
import com.yunbao.common.manager.SWManager;
|
||||||
import com.yunbao.common.utils.Bus;
|
import com.yunbao.common.utils.Bus;
|
||||||
import com.yunbao.common.utils.DialogUitl;
|
import com.yunbao.common.utils.DialogUitl;
|
||||||
import com.yunbao.common.utils.DpUtil;
|
import com.yunbao.common.utils.DpUtil;
|
||||||
@ -70,26 +71,19 @@ import org.greenrobot.eventbus.ThreadMode;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import cn.rongcloud.rtc.api.RCRTCConfig;
|
|
||||||
import cn.rongcloud.rtc.api.RCRTCEngine;
|
import cn.rongcloud.rtc.api.RCRTCEngine;
|
||||||
import cn.rongcloud.rtc.api.RCRTCMixConfig;
|
import cn.rongcloud.rtc.api.RCRTCMixConfig;
|
||||||
import cn.rongcloud.rtc.api.RCRTCRemoteUser;
|
import cn.rongcloud.rtc.api.RCRTCRemoteUser;
|
||||||
import cn.rongcloud.rtc.api.RCRTCRoom;
|
import cn.rongcloud.rtc.api.RCRTCRoom;
|
||||||
import cn.rongcloud.rtc.api.RCRTCRoomConfig;
|
|
||||||
import cn.rongcloud.rtc.api.callback.IRCRTCEngineEventListener;
|
|
||||||
import cn.rongcloud.rtc.api.callback.IRCRTCResultCallback;
|
import cn.rongcloud.rtc.api.callback.IRCRTCResultCallback;
|
||||||
import cn.rongcloud.rtc.api.callback.IRCRTCResultDataCallback;
|
import cn.rongcloud.rtc.api.callback.IRCRTCResultDataCallback;
|
||||||
import cn.rongcloud.rtc.api.callback.IRCRTCRoomEventsListener;
|
import cn.rongcloud.rtc.api.callback.IRCRTCRoomEventsListener;
|
||||||
import cn.rongcloud.rtc.api.stream.RCRTCInputStream;
|
import cn.rongcloud.rtc.api.stream.RCRTCInputStream;
|
||||||
import cn.rongcloud.rtc.api.stream.RCRTCLiveInfo;
|
import cn.rongcloud.rtc.api.stream.RCRTCLiveInfo;
|
||||||
import cn.rongcloud.rtc.api.stream.RCRTCVideoStreamConfig;
|
|
||||||
import cn.rongcloud.rtc.api.stream.RCRTCVideoView;
|
|
||||||
import cn.rongcloud.rtc.base.RCRTCParamsType;
|
import cn.rongcloud.rtc.base.RCRTCParamsType;
|
||||||
import cn.rongcloud.rtc.base.RCRTCRoomType;
|
|
||||||
import cn.rongcloud.rtc.base.RCRTCVideoEventCode;
|
|
||||||
import cn.rongcloud.rtc.base.RTCErrorCode;
|
import cn.rongcloud.rtc.base.RTCErrorCode;
|
||||||
import cn.rongcloud.rtc.core.CameraVideoCapturer;
|
import cn.rongcloud.rtc.core.CameraVideoCapturer;
|
||||||
import cn.rongcloud.rtc.core.RendererCommon;
|
import io.agora.rtc2.RtcEngine;
|
||||||
import io.rong.imlib.IRongCallback;
|
import io.rong.imlib.IRongCallback;
|
||||||
import io.rong.imlib.RongIMClient;
|
import io.rong.imlib.RongIMClient;
|
||||||
import io.rong.imlib.model.Conversation;
|
import io.rong.imlib.model.Conversation;
|
||||||
@ -101,13 +95,12 @@ import io.rong.message.TextMessage;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITXLivePushListener {
|
public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITXLivePushListener {
|
||||||
|
private RtcEngine mRtcEngine;
|
||||||
private int mMeiBaiVal;//基础美颜 美白
|
private int mMeiBaiVal;//基础美颜 美白
|
||||||
private int mMoPiVal;//基础美颜 磨皮
|
private int mMoPiVal;//基础美颜 磨皮
|
||||||
private int mHongRunVal;//基础美颜 红润
|
private int mHongRunVal;//基础美颜 红润
|
||||||
private String mBgmPath;//背景音乐路径
|
private String mBgmPath;//背景音乐路径
|
||||||
private Bitmap mFilterBmp;
|
private Bitmap mFilterBmp;
|
||||||
|
|
||||||
private TXDeviceManager mTXDeviceManager;
|
private TXDeviceManager mTXDeviceManager;
|
||||||
private TRTCCloudDef.TRTCParams mTRTCParams;
|
private TRTCCloudDef.TRTCParams mTRTCParams;
|
||||||
private Handler mMainHandler;
|
private Handler mMainHandler;
|
||||||
@ -117,7 +110,6 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
|
|||||||
public LinearLayout dr_pk_view;
|
public LinearLayout dr_pk_view;
|
||||||
public static RCRTCRoom rtcRoom;
|
public static RCRTCRoom rtcRoom;
|
||||||
public static RCRTCLiveInfo rcrtcLiveInfo;
|
public static RCRTCLiveInfo rcrtcLiveInfo;
|
||||||
|
|
||||||
private ViewGroup liveActivityContainer;
|
private ViewGroup liveActivityContainer;
|
||||||
public FrameLayout timeTitle;
|
public FrameLayout timeTitle;
|
||||||
public TextView textTime;
|
public TextView textTime;
|
||||||
@ -126,6 +118,7 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
|
|||||||
private LinearLayout goto_room_view;
|
private LinearLayout goto_room_view;
|
||||||
private boolean isPk = false;
|
private boolean isPk = false;
|
||||||
private boolean isNeedOpenCamera = false;
|
private boolean isNeedOpenCamera = false;
|
||||||
|
private SWManager swManager;
|
||||||
|
|
||||||
//修改上面主播的头像
|
//修改上面主播的头像
|
||||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
@ -139,7 +132,6 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
|
|||||||
goto_room_view.setVisibility(View.VISIBLE);
|
goto_room_view.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
goto_room_view.setVisibility(View.GONE);
|
goto_room_view.setVisibility(View.GONE);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -414,7 +406,7 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(String error) {
|
public void onError(String error) {
|
||||||
ToastUtil.show(WordUtil.isNewZh()?"抱歉!出錯了!":"i \\'m sorry! An error occurred");
|
ToastUtil.show(WordUtil.isNewZh() ? "抱歉!出錯了!" : "i \\'m sorry! An error occurred");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -470,7 +462,6 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init() {
|
public void init() {
|
||||||
super.init();
|
super.init();
|
||||||
@ -615,8 +606,9 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
initRtcEngine();
|
||||||
|
|
||||||
// 构建 RoomConfig,指定房间类型和主播身份:
|
/* // 构建 RoomConfig,指定房间类型和主播身份:
|
||||||
RCRTCRoomConfig roomConfig = RCRTCRoomConfig.Builder.create()
|
RCRTCRoomConfig roomConfig = RCRTCRoomConfig.Builder.create()
|
||||||
// 根据实际场景,选择音视频直播:LIVE_AUDIO_VIDEO 或音频直播:LIVE_AUDIO
|
// 根据实际场景,选择音视频直播:LIVE_AUDIO_VIDEO 或音频直播:LIVE_AUDIO
|
||||||
.setRoomType(RCRTCRoomType.LIVE_AUDIO_VIDEO)
|
.setRoomType(RCRTCRoomType.LIVE_AUDIO_VIDEO)
|
||||||
@ -772,9 +764,24 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化声网SDK
|
||||||
|
*/
|
||||||
|
private void initRtcEngine() {
|
||||||
|
swManager = SWManager.get();
|
||||||
|
swManager.setAnchorContainer(mPreView);
|
||||||
|
swManager.initRtcEngine((Activity) mContext, "11");
|
||||||
|
swManager.setOnRtcEngineListener(new SWManager.onRtcEngineListener() {
|
||||||
|
@Override
|
||||||
|
public void onOpenSuccess(String channel, int uid) {
|
||||||
|
//开播成功
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void changeToLeft() {
|
public void changeToLeft() {
|
||||||
@ -847,6 +854,10 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void startPush(String pushUrl) {
|
public void startPush(String pushUrl) {
|
||||||
|
//开播成功,创建频道
|
||||||
|
if (swManager != null) {
|
||||||
|
swManager.createRoom(SWManager.shengwang_token, SWManager.shengwang_channelName);
|
||||||
|
}
|
||||||
if (rcrtcLiveInfo != null) {
|
if (rcrtcLiveInfo != null) {
|
||||||
rcrtcLiveInfo.addPublishStreamUrl(pushUrl, new IRCRTCResultDataCallback<String[]>() {
|
rcrtcLiveInfo.addPublishStreamUrl(pushUrl, new IRCRTCResultDataCallback<String[]>() {
|
||||||
@Override
|
@Override
|
||||||
@ -946,7 +957,7 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
|
|||||||
public void onResume() {
|
public void onResume() {
|
||||||
mPaused = false;
|
mPaused = false;
|
||||||
Log.i("摄像头", "onResume: " + isNeedOpenCamera);
|
Log.i("摄像头", "onResume: " + isNeedOpenCamera);
|
||||||
if(isNeedOpenCamera){
|
if (isNeedOpenCamera) {
|
||||||
RCRTCEngine.getInstance().getDefaultVideoStream().startCamera(new IRCRTCResultDataCallback<Boolean>() {
|
RCRTCEngine.getInstance().getDefaultVideoStream().startCamera(new IRCRTCResultDataCallback<Boolean>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Boolean data) {
|
public void onSuccess(Boolean data) {
|
||||||
|
37
live/src/main/res/layout/acticity_new_live.xml
Normal file
37
live/src/main/res/layout/acticity_new_live.xml
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context=".activity.NewLiveActivity">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Start Video Call!"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/local_video_view_container"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="@android:color/white" />
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/remote_video_view_container"
|
||||||
|
android:layout_width="160dp"
|
||||||
|
android:layout_height="160dp"
|
||||||
|
android:layout_alignParentTop="true"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:layout_marginEnd="16dp"
|
||||||
|
android:layout_marginRight="16dp"
|
||||||
|
android:background="@android:color/darker_gray"
|
||||||
|
tools:ignore="MissingConstraints" />
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -12,8 +12,14 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
app:surface_type="texture_view"
|
app:surface_type="texture_view"
|
||||||
app:use_controller="false"
|
app:use_controller="false"
|
||||||
|
android:visibility="gone"
|
||||||
android:layout_height="match_parent" />
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/playView"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/leave"
|
android:id="@+id/leave"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -54,6 +54,7 @@ import com.yunbao.common.utils.WordUtil;
|
|||||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||||
import com.yunbao.common.http.LiveHttpUtil;
|
import com.yunbao.common.http.LiveHttpUtil;
|
||||||
import com.yunbao.common.utils.LiveRoomCheckLivePresenter;
|
import com.yunbao.common.utils.LiveRoomCheckLivePresenter;
|
||||||
|
import com.yunbao.live.activity.NewLiveActivity;
|
||||||
import com.yunbao.main.R;
|
import com.yunbao.main.R;
|
||||||
import com.yunbao.main.event.RegSuccessEvent;
|
import com.yunbao.main.event.RegSuccessEvent;
|
||||||
import com.yunbao.main.http.MainHttpConsts;
|
import com.yunbao.main.http.MainHttpConsts;
|
||||||
@ -173,6 +174,8 @@ public class LoginActivity extends AbsActivity {
|
|||||||
public void onViewClicks() {
|
public void onViewClicks() {
|
||||||
int i = v.getId();
|
int i = v.getId();
|
||||||
if (i == R.id.btn_login) {
|
if (i == R.id.btn_login) {
|
||||||
|
//Intent intent = new Intent(LoginActivity.this, NewLiveActivity.class);
|
||||||
|
//startActivity(intent);
|
||||||
login();
|
login();
|
||||||
|
|
||||||
} else if (i == R.id.btn_register) {
|
} else if (i == R.id.btn_register) {
|
||||||
@ -240,7 +243,7 @@ public class LoginActivity extends AbsActivity {
|
|||||||
|
|
||||||
//登录即代表同意服务和隐私条款
|
//登录即代表同意服务和隐私条款
|
||||||
private void forwardTip() {
|
private void forwardTip() {
|
||||||
WebViewActivity.forward(mContext, HtmlConfig.LOGIN_PRIVCAY+ "&isZh=" + (WordUtil.isNewZh() ? "1" : "0"),false);
|
WebViewActivity.forward(mContext, HtmlConfig.LOGIN_PRIVCAY + "&isZh=" + (WordUtil.isNewZh() ? "1" : "0"), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user