|
|
@ -66,6 +66,7 @@ public class LiveActivity extends AppCompatActivity implements View.OnClickListe |
|
|
|
private void initView(){ |
|
|
|
private void initView(){ |
|
|
|
findViewById(R.id.btn_swap).setOnClickListener(this); |
|
|
|
findViewById(R.id.btn_swap).setOnClickListener(this); |
|
|
|
((ToggleButton)findViewById(R.id.btn_live)).setOnCheckedChangeListener(this); |
|
|
|
((ToggleButton)findViewById(R.id.btn_live)).setOnCheckedChangeListener(this); |
|
|
|
|
|
|
|
((ToggleButton)findViewById(R.id.btn_mute)).setOnCheckedChangeListener(this); |
|
|
|
SurfaceView surface_camera = (SurfaceView) findViewById(R.id.surface_camera); |
|
|
|
SurfaceView surface_camera = (SurfaceView) findViewById(R.id.surface_camera); |
|
|
|
surfaceHolder = surface_camera.getHolder(); |
|
|
|
surfaceHolder = surface_camera.getHolder(); |
|
|
|
} |
|
|
|
} |
|
|
@ -87,18 +88,28 @@ public class LiveActivity extends AppCompatActivity implements View.OnClickListe |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onClick(View v) { |
|
|
|
public void onClick(View v) { |
|
|
|
if(v.getId() == R.id.btn_swap){ |
|
|
|
if(v.getId() == R.id.btn_swap){//切换摄像头
|
|
|
|
livePusher.switchCamera(); |
|
|
|
livePusher.switchCamera(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { |
|
|
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { |
|
|
|
|
|
|
|
switch (buttonView.getId()){ |
|
|
|
|
|
|
|
case R.id.btn_live://开始/停止直播
|
|
|
|
if(isChecked){ |
|
|
|
if(isChecked){ |
|
|
|
livePusher.startPush(LIVE_URL, this); |
|
|
|
livePusher.startPush(LIVE_URL, this); |
|
|
|
}else { |
|
|
|
}else { |
|
|
|
livePusher.stopPush(); |
|
|
|
livePusher.stopPush(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case R.id.btn_mute://设置静音
|
|
|
|
|
|
|
|
Log.i(TAG, "isChecked=" + isChecked); |
|
|
|
|
|
|
|
livePusher.setMute(isChecked); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|