修复了在线状态的bug
This commit is contained in:
@@ -29,6 +29,8 @@ public abstract class BaseLiveActivity extends AppCompatActivity {
|
||||
protected ToggleButton btnLive;
|
||||
// 保存文件到本地
|
||||
private ToggleButton btnSaveFile;
|
||||
// 设置摄像头与状态
|
||||
private ToggleButton btnChangeCameraState;
|
||||
|
||||
// 相机数据预览
|
||||
protected SurfaceView surfaceView;
|
||||
@@ -56,6 +58,12 @@ public abstract class BaseLiveActivity extends AppCompatActivity {
|
||||
}
|
||||
});
|
||||
|
||||
btnChangeCameraState = findViewById(R.id.btnChangeCameraState);
|
||||
btnChangeCameraState.setOnCheckedChangeListener((btnSaveFile, isChecked) -> {
|
||||
Toast.makeText(getApplicationContext(), btnSaveFile.getText(), Toast.LENGTH_SHORT).show();
|
||||
toggleCameraState(isChecked);
|
||||
});
|
||||
|
||||
initCamer();
|
||||
}
|
||||
|
||||
@@ -139,4 +147,11 @@ public abstract class BaseLiveActivity extends AppCompatActivity {
|
||||
*/
|
||||
public abstract void toggleLive(boolean isLive);
|
||||
|
||||
/**
|
||||
* 摄像头状态
|
||||
*
|
||||
* @param isLive true-可以直播,false-不可以直播
|
||||
*/
|
||||
public abstract void toggleCameraState(boolean isLive);
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.mogo.cloud;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
import com.mogo.cloud.live.manager.ILiveStreamManager;
|
||||
import com.mogo.cloud.live.manager.LiveStreamManagerImpl;
|
||||
@@ -20,7 +21,6 @@ public class LivePushActivity extends BaseLiveActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
// 初始化直播流管理
|
||||
liveStreamManager = LiveStreamManagerImpl.getInstance(this, MoGoAiCloudClientConfig.getInstance().getSn());
|
||||
liveStreamManager.uploadCamStatus(1, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -37,6 +37,16 @@ public class LivePushActivity extends BaseLiveActivity {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toggleCameraState(boolean isLive) {
|
||||
Log.i(TAG, "toggleCameraState isLive: " + isLive);
|
||||
if (isLive) {
|
||||
liveStreamManager.uploadCamStatus(1, 1);
|
||||
} else {
|
||||
liveStreamManager.uploadCamStatus(2, 2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
@@ -8,19 +8,6 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<!-- <com.baidu.rtc.RTCVideoView-->
|
||||
<!-- android:id="@+id/rtcView"-->
|
||||
<!-- android:layout_width="860px"-->
|
||||
<!-- android:layout_height="540px"-->
|
||||
<!-- android:layout_below="@+id/surfaceView" />-->
|
||||
|
||||
<!-- <com.baidu.rtc.RTCVideoView-->
|
||||
<!-- android:id="@+id/rtcRemoteView"-->
|
||||
<!-- android:layout_width="900px"-->
|
||||
<!-- android:layout_height="540px"-->
|
||||
<!-- android:layout_alignParentRight="true"-->
|
||||
<!-- android:layout_below="@+id/surfaceView" />-->
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/flTestPanel"
|
||||
@@ -37,6 +24,14 @@
|
||||
android:textOff="@string/start"
|
||||
android:textOn="@string/stop" />
|
||||
|
||||
<ToggleButton
|
||||
android:id="@+id/btnChangeCameraState"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
android:textOff="设置不可直播"
|
||||
android:textOn="设置可直播" />
|
||||
|
||||
<ToggleButton
|
||||
android:id="@+id/btnSaveFile"
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
Reference in New Issue
Block a user