增加了单独登录第二个房间的测试
This commit is contained in:
@@ -41,6 +41,8 @@ public abstract class BaseLiveActivity extends AppCompatActivity {
|
||||
protected SurfaceView surfacePlayView;
|
||||
// 查看直播按钮
|
||||
protected ToggleButton liveToggleBtn;
|
||||
// 登录第二个房间的按钮
|
||||
protected ToggleButton tbLoginMultiRoom;
|
||||
// 要查看的车机SN
|
||||
protected EditText etLookRoomId;
|
||||
// WIFI状态
|
||||
@@ -84,6 +86,13 @@ public abstract class BaseLiveActivity extends AppCompatActivity {
|
||||
Toast.makeText(getApplicationContext(), buttonView.getText(), Toast.LENGTH_SHORT).show();
|
||||
togglePlay(isChecked);
|
||||
});
|
||||
|
||||
|
||||
tbLoginMultiRoom = findViewById(R.id.tbLoginMultiRoom);
|
||||
tbLoginMultiRoom.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||
Toast.makeText(getApplicationContext(), buttonView.getText(), Toast.LENGTH_SHORT).show();
|
||||
toggleLoginMultiRoom(isChecked);
|
||||
});
|
||||
tvWifiState = findViewById(R.id.tvWifiState);
|
||||
|
||||
initCamer();
|
||||
@@ -183,4 +192,11 @@ public abstract class BaseLiveActivity extends AppCompatActivity {
|
||||
*/
|
||||
public abstract void togglePlay(boolean isPlay);
|
||||
|
||||
/**
|
||||
* 登录或退出第二个房间
|
||||
*
|
||||
* @param isLogin true-登录,false-退出
|
||||
*/
|
||||
public abstract void toggleLoginMultiRoom(boolean isLogin);
|
||||
|
||||
}
|
||||
@@ -5,7 +5,6 @@ import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
import com.mogo.cloud.live.listener.ILiveStatusListener;
|
||||
import com.mogo.cloud.live.manager.ILiveStreamManager;
|
||||
import com.mogo.cloud.live.manager.LiveStreamManagerImpl;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
import com.mogo.cloud.trafficlive.api.ITrafficLiveCallBack;
|
||||
@@ -18,12 +17,13 @@ import com.mogo.cloud.wifi.WifiStateManager;
|
||||
/**
|
||||
* 推流和拉流页面
|
||||
*/
|
||||
public class LivePlayAndPushActivity extends BaseLiveActivity implements ITrafficLiveCallBack, IWifiStateListener {
|
||||
public class LivePlayAndPushActivity extends BaseLiveActivity
|
||||
implements ITrafficLiveCallBack, IWifiStateListener {
|
||||
public static final String TAG = "LivePlayAndPushActivity";
|
||||
|
||||
private String liveSn;
|
||||
|
||||
ILiveStreamManager liveStreamManager;
|
||||
LiveStreamManagerImpl liveStreamManager;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -67,7 +67,7 @@ public class LivePlayAndPushActivity extends BaseLiveActivity implements ITraffi
|
||||
public void toggleLive(boolean isLive) {
|
||||
if (isLive) {
|
||||
liveStreamManager.startLiveStream();
|
||||
}else{
|
||||
} else {
|
||||
liveStreamManager.stopLiveStream();
|
||||
}
|
||||
}
|
||||
@@ -94,6 +94,16 @@ public class LivePlayAndPushActivity extends BaseLiveActivity implements ITraffi
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toggleLoginMultiRoom(boolean isLogin) {
|
||||
if (isLogin) {
|
||||
liveSn = etLookRoomId.getText().toString().trim();
|
||||
liveStreamManager.getLivePusher().loginMultiRoom(liveSn);
|
||||
} else {
|
||||
liveStreamManager.getLivePusher().logoutMultiRoom();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
@@ -74,6 +74,11 @@ public class LivePushActivity extends BaseLiveActivity {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toggleLoginMultiRoom(boolean isLogin) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
@@ -101,12 +101,21 @@
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="请输入要查看的车机SN"
|
||||
android:text="F803EB2046PZD00149"
|
||||
android:text="F803BB2037EZD00048"
|
||||
android:textColor="#FFFF"
|
||||
app:layout_constraintBottom_toTopOf="@+id/liveToggleBtn"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="@+id/surfacePlayView" />
|
||||
|
||||
<ToggleButton
|
||||
android:id="@+id/tbLoginMultiRoom"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textOff="登录第二个房间"
|
||||
android:textOn="退出第二个房间"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="@+id/etLookRoomId" />
|
||||
|
||||
<ToggleButton
|
||||
android:id="@+id/liveToggleBtn"
|
||||
android:layout_width="wrap_content"
|
||||
@@ -114,7 +123,7 @@
|
||||
android:textOff="开始拉流"
|
||||
android:textOn="停止拉流"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="@+id/etLookRoomId" />
|
||||
app:layout_constraintLeft_toRightOf="@+id/tbLoginMultiRoom" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvWifiState"
|
||||
|
||||
@@ -24,7 +24,7 @@ import com.mogo.cloud.utils.logger.Logger;
|
||||
public class LiveStreamManagerImpl implements ILiveStreamManager {
|
||||
private static final String TAG = "LiveStreamManagerImpl";
|
||||
|
||||
private static volatile ILiveStreamManager sInstance;
|
||||
private static volatile LiveStreamManagerImpl sInstance;
|
||||
|
||||
private final Application mApplication;
|
||||
|
||||
@@ -41,11 +41,12 @@ public class LiveStreamManagerImpl implements ILiveStreamManager {
|
||||
private SocketMsgUtils mSocketMsgUtils; // Socket 长链接
|
||||
private ILiveStatusListener mLiveStatusCallback;// 直播状态回调
|
||||
private MoGoLivePushConfig mLivePushConfig;// 直播参数
|
||||
private MoGoLiveManager mLivePusher; // 自研直播SDK
|
||||
private static final int WIDTH = 1280;
|
||||
private static final int HEIGHT = 720;
|
||||
|
||||
|
||||
public static ILiveStreamManager getInstance(Application application, String devicesId) {
|
||||
public static LiveStreamManagerImpl getInstance(Application application, String devicesId) {
|
||||
if (sInstance == null) {
|
||||
synchronized (LiveStreamManagerImpl.class) {
|
||||
if (sInstance == null) {
|
||||
@@ -73,7 +74,7 @@ public class LiveStreamManagerImpl implements ILiveStreamManager {
|
||||
mLivePushConfig.setMute(true);
|
||||
mLivePushConfig.setDevicesId(devicesId);
|
||||
// 初始化直播
|
||||
MoGoLiveManager.getInstance().init(mApplication, mLivePushConfig);
|
||||
mLivePusher = MoGoLiveManager.getInstance().init(mApplication, mLivePushConfig);
|
||||
|
||||
// 初始化Socket长连接通道
|
||||
mSocketMsgUtils = SocketMsgUtils.getInstance(mApplication,
|
||||
@@ -95,6 +96,10 @@ public class LiveStreamManagerImpl implements ILiveStreamManager {
|
||||
|
||||
}
|
||||
|
||||
public MoGoLiveManager getLivePusher() {
|
||||
return mLivePusher;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取前置摄像头直播状态
|
||||
*/
|
||||
|
||||
@@ -418,7 +418,7 @@ public class MoGoLiveManager {
|
||||
/**
|
||||
* 退出房间
|
||||
*/
|
||||
private void logOutRoom() {
|
||||
public void logoutRoom() {
|
||||
if (mExpressEngine == null) {
|
||||
return;
|
||||
}
|
||||
@@ -438,7 +438,7 @@ public class MoGoLiveManager {
|
||||
/**
|
||||
* 退出多房间
|
||||
*/
|
||||
private void logOutMultiRoom() {
|
||||
public void logoutMultiRoom() {
|
||||
if (mExpressEngine == null) {
|
||||
return;
|
||||
}
|
||||
@@ -531,7 +531,7 @@ public class MoGoLiveManager {
|
||||
}
|
||||
mExpressEngine.stopPreview();
|
||||
// 退出正在查看的多房间
|
||||
logOutMultiRoom();
|
||||
logoutMultiRoom();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user