写的回调里只有加入频道结果回调触发了,其他都没有反应,结果是能听到音频看不到远程的视频信息
private final AliRtcEngineNotify mNotify= new AliRtcEngineNotify() {
@Override
public void onRemoteUserOnLineNotify(String uid, int elapsed){
runOnUiThread(new Runnable() {
@Override
public void run() {
LinearLayoutCompat layout= findViewById(R.id.remote);
SurfaceView mRemoteView =engine.createRenderSurfaceView(getApplicationContext());
mRemoteView.setZOrderMediaOverlay(true);
layout.addView(mRemoteView);
AliRtcEngine.AliRtcVideoCanvas canvas = new AliRtcEngine.AliRtcVideoCanvas();
canvas.renderMode = AliRtcRenderModeAuto/* renderMode */;
canvas.view = mRemoteView;/* 渲染view */
engine.setRemoteViewConfig(canvas, uid, AliRtcVideoTrackCamera);
}
});
}
@Override
public void onRemoteTrackAvailableNotify(String uid, AliRtcEngine.AliRtcAudioTrack audioTrack,
AliRtcEngine.AliRtcVideoTrack videoTrack) {
// UI或者逻辑处理,例如渲染远端视频流的操作如下。
if(videoTrack == AliRtcVideoTrackCamera) {
runOnUiThread(new Runnable() {
@Override
public void run() {
LinearLayoutCompat layout= findViewById(R.id.remote);
SurfaceView mLocalView=engine.createRenderSurfaceView(getApplicationContext());
mLocalView.setZOrderMediaOverlay(true);
layout.addView(mLocalView);
AliRtcEngine.AliRtcVideoCanvas canvas = new AliRtcEngine.AliRtcVideoCanvas();
canvas.renderMode = AliRtcRenderModeAuto/* renderMode */;
canvas.view = mLocalView;/* 渲染view */
engine.setRemoteViewConfig(canvas, uid, AliRtcVideoTrackCamera);
}
});
}
}
@Override
public void onFirstVideoFrameReceived(String uid, AliRtcEngine.AliRtcVideoTrack videoTrack, int timeCost){
if(videoTrack == AliRtcVideoTrackCamera) {
runOnUiThread(new Runnable() {
@Override
public void run() {
LinearLayoutCompat layout= findViewById(R.id.remote);
SurfaceView mRemoteView =engine.createRenderSurfaceView(getApplicationContext());
mRemoteView.setZOrderMediaOverlay(true);
layout.addView(mRemoteView);
AliRtcEngine.AliRtcVideoCanvas canvas = new AliRtcEngine.AliRtcVideoCanvas();
canvas.renderMode = AliRtcRenderModeAuto/* renderMode */;
canvas.view = mRemoteView;/* 渲染view */
engine.setRemoteViewConfig(canvas, "uid", AliRtcVideoTrackCamera);
}
});
}
}
};
private final AliRtcEngineEventListener mListener = new AliRtcEngineEventListener() {
@Override
public void onVideoPublishStateChanged(AliRtcEngine.AliRtcPublishState oldState ,
AliRtcEngine.AliRtcPublishState newState,
int elapseSinceLastState, String channel){
Looper.prepare();
Toast.makeText(MainActivity.this,"old:"+oldState+",new:"+newState,Toast.LENGTH_SHORT).show();
Looper.loop();
}
@Override
public void onVideoSubscribeStateChanged(String uid,
AliRtcEngine.AliRtcSubscribeState oldState,
AliRtcEngine.AliRtcSubscribeState newState,
int elapseSinceLastState, String channel){
Looper.prepare();
Toast.makeText(MainActivity.this,uid+" old:"+oldState+" new:"+newState,Toast.LENGTH_SHORT).show();
Looper.loop();
}
@Override
public void onJoinChannelResult(int result, String channel, int elapsed) {
Looper.prepare();
if(result==0)
Toast.makeText(MainActivity.this,"加入成功",Toast.LENGTH_SHORT).show();
else Toast.makeText(MainActivity.this,"加入失败,错误码为"+result,Toast.LENGTH_SHORT).show();
engine.publishLocalAudioStream(true);
engine.publishLocalVideoStream(true);
engine.setDefaultSubscribeAllRemoteAudioStreams(true);
engine.setDefaultSubscribeAllRemoteVideoStreams(true);
Log.e("log",String.valueOf(engine.isLocalVideoStreamPublished()));
/*runOnUiThread(new Runnable() {
@Override
public void run() {
LinearLayoutCompat layout= findViewById(R.id.remote);
SurfaceView mRemoteView =engine.createRenderSurfaceView(getApplicationContext());
mRemoteView.setZOrderMediaOverlay(true);
layout.addView(mRemoteView);
AliRtcEngine.AliRtcVideoCanvas canvas = new AliRtcEngine.AliRtcVideoCanvas();
canvas.renderMode = AliRtcRenderModeAuto*//* renderMode *//*;
canvas.view = mRemoteView;*//* 渲染view *//*
engine.setRemoteViewConfig(canvas, "uid", AliRtcVideoTrackCamera);
}
});*/
Looper.loop();
}
@Override
public void onLeaveChannelResult(int result, AliRtcEngine.AliRtcStats stats){
Looper.prepare();
if(result==0)
Toast.makeText(MainActivity.this,"离开成功",Toast.LENGTH_SHORT).show();
else Toast.makeText(MainActivity.this,"离开失败,错误码为"+result,Toast.LENGTH_SHORT).show();
Looper.loop();
}
};
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。