增加了状态回碉
增加了如果直播间没有观众的时候自动关闭直播
This commit is contained in:
@@ -33,7 +33,7 @@ public abstract class BaseLiveActivity extends AppCompatActivity {
|
||||
// 设置摄像头与状态
|
||||
protected ToggleButton btnChangeCameraState;
|
||||
// 当前直播的状态
|
||||
protected ToggleButton tbLiveStatus;
|
||||
protected TextView tvLiveStatus;
|
||||
// 相机数据预览
|
||||
protected SurfaceView surfacePreviewView;
|
||||
|
||||
@@ -77,7 +77,7 @@ public abstract class BaseLiveActivity extends AppCompatActivity {
|
||||
toggleCameraState(isChecked);
|
||||
});
|
||||
|
||||
tbLiveStatus = findViewById(R.id.tbLiveStatus);
|
||||
tvLiveStatus = findViewById(R.id.tvLiveStatus);
|
||||
|
||||
surfacePlayView = findViewById(R.id.surfacePlayView);
|
||||
etLookRoomId = findViewById(R.id.etLookRoomId);
|
||||
|
||||
@@ -38,15 +38,18 @@ public class LivePlayAndPushActivity extends BaseLiveActivity
|
||||
liveStreamManager.setLiveStatusChangeCallback(new ILiveStatusListener() {
|
||||
@Override
|
||||
public void onChange(String camId, int status) {
|
||||
tbLiveStatus.post(new Runnable() {
|
||||
tvLiveStatus.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (status == 0) {
|
||||
tbLiveStatus.setTextColor(getResources().getColor(R.color.colorStartLive));
|
||||
tbLiveStatus.setChecked(true);
|
||||
} else {
|
||||
tbLiveStatus.setTextColor(getResources().getColor(R.color.colorStopLive));
|
||||
tbLiveStatus.setChecked(false);
|
||||
tvLiveStatus.setTextColor(getResources().getColor(R.color.colorStartLive));
|
||||
tvLiveStatus.setText("正在直播中");
|
||||
} else if (status == 1) {
|
||||
tvLiveStatus.setTextColor(getResources().getColor(R.color.colorStopLive));
|
||||
tvLiveStatus.setText("直播已停止");
|
||||
} else if (status == 2) {
|
||||
tvLiveStatus.setTextColor(getResources().getColor(R.color.colorForcedStopLive));
|
||||
tvLiveStatus.setText("直播强制结束");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -28,15 +28,13 @@ public class LivePushActivity extends BaseLiveActivity {
|
||||
liveStreamManager.setLiveStatusChangeCallback(new ILiveStatusListener() {
|
||||
@Override
|
||||
public void onChange(String camId, int status) {
|
||||
tbLiveStatus.post(new Runnable() {
|
||||
tvLiveStatus.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (status == 0) {
|
||||
tbLiveStatus.setTextColor(getResources().getColor(R.color.colorStartLive));
|
||||
tbLiveStatus.setChecked(true);
|
||||
tvLiveStatus.setTextColor(getResources().getColor(R.color.colorStartLive));
|
||||
} else {
|
||||
tbLiveStatus.setTextColor(getResources().getColor(R.color.colorStopLive));
|
||||
tbLiveStatus.setChecked(false);
|
||||
tvLiveStatus.setTextColor(getResources().getColor(R.color.colorStopLive));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user