62 lines
1.9 KiB
Java
62 lines
1.9 KiB
Java
package com.mogo.cloud;
|
|
|
|
import android.os.Bundle;
|
|
import android.util.Log;
|
|
import android.view.SurfaceView;
|
|
import android.widget.EditText;
|
|
import android.widget.Toast;
|
|
import android.widget.ToggleButton;
|
|
|
|
import androidx.appcompat.app.AppCompatActivity;
|
|
|
|
import com.mogo.cloud.trafficlive.api.ITrafficLiveCallBack;
|
|
import com.mogo.cloud.trafficlive.api.MoGoAiCloudTrafficLive;
|
|
|
|
|
|
public class LivePlayActivity extends AppCompatActivity implements ITrafficLiveCallBack {
|
|
private String TAG = "LiveActivity";
|
|
|
|
private SurfaceView surfaceView;
|
|
private ToggleButton liveToggleBtn;
|
|
private EditText etLookRoomId;
|
|
|
|
@Override
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
super.onCreate(savedInstanceState);
|
|
setContentView(R.layout.activity_live_play);
|
|
surfaceView = findViewById(R.id.surfaceView);
|
|
etLookRoomId = findViewById(R.id.etLookRoomId);
|
|
liveToggleBtn = findViewById(R.id.liveToggleBtn);
|
|
liveToggleBtn.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
|
Toast.makeText(getApplicationContext(), buttonView.getText(), Toast.LENGTH_SHORT).show();
|
|
if (isChecked) {
|
|
String roomId = etLookRoomId.getText().toString().trim();
|
|
MoGoAiCloudTrafficLive.viewVehicleHeadLive(this.getApplication(), roomId, surfaceView, this);
|
|
} else {
|
|
MoGoAiCloudTrafficLive.stopLive();
|
|
}
|
|
});
|
|
}
|
|
|
|
@Override
|
|
protected void onDestroy() {
|
|
super.onDestroy();
|
|
MoGoAiCloudTrafficLive.stopLive();
|
|
MoGoAiCloudTrafficLive.destroyLive();
|
|
}
|
|
|
|
@Override
|
|
public void onLive() {
|
|
Log.d(TAG, "开始直播 onLive");
|
|
}
|
|
|
|
@Override
|
|
public void onDisConnect() {
|
|
Log.d(TAG, "失去连接 onDisConnect");
|
|
}
|
|
|
|
@Override
|
|
public void onError(String errorMsg) {
|
|
Log.d(TAG, "发生错误 onError msg: " + errorMsg);
|
|
}
|
|
} |