我目前正在尝试Android Sinch
SDK,所以我目前正在开发一个测试应用来尝试一些功能。我成功地向应用程序调用了一个语音应用程序,但我在尝试应用程序调用视频应用程序时出现问题:当建立连接时,调用者可以显示远程视频,但收件人无法显示远程视频(两者都有)可以显示他们的本地视频)。
这是我的代码:
通话清单
public class SinchVidListner implements VideoCallListener {
private Activity a ;
private TextView callState ;
private Button dec ;
private LinearLayout gl ;
public SinchVidListner(Activity act)
{
a=act;
callState = (TextView) a.findViewById(R.id.fullscreen_content);
dec=(Button) a.findViewById(R.id.Decline) ;
}
@Override
public void onVideoTrackAdded(Call call) {
//remoteView = vc.getRemoteView();
}
@Override
public void onCallProgressing(Call call) {
callState.setText("Ringing");
}
@Override
public void onCallEstablished(Call call) {
DataHolder.getInstance().stop();
a.setVolumeControlStream(AudioManager.USE_DEFAULT_STREAM_TYPE);
callState.setText("");
dec.setVisibility(View.GONE);
if (! DataHolder.getInstance().isVidadd())
{VideoController vc = DataHolder.getInstance().getClient().getVideoController();
gl= (LinearLayout) a.findViewById(R.id.trust) ;
gl.removeAllViews();
gl.addView(vc.getLocalView());
DataHolder.getInstance().setVidadd(true);}
}
@Override
public void onCallEnded(Call call) {
DataHolder.getInstance().setCall(null);
Button button = (Button) a.findViewById(R.id.call) ;
button.setText("Call");
a.setVolumeControlStream(AudioManager.USE_DEFAULT_STREAM_TYPE);
gl.removeAllViews();
callState.setText("Call ended");
DataHolder.getInstance().stop();
dec.setVisibility(View.GONE);
}
@Override
public void onShouldSendPushNotification(Call call, List<PushPair> list) {
}
}
来电列表
public class SinchCallClientListener implements CallClientListener {
Activity a ;
Call call ;
public SinchCallClientListener(Activity activity) {
a=activity ;
}
@Override
public void onIncomingCall(CallClient callClient, Call incomingCall) {
Button button = (Button) a.findViewById(R.id.call) ;
//call = incomingCall;
//call.answer();
if (! incomingCall.getDetails().isVideoOffered())
{incomingCall.addCallListener(new SinchCallListener(a));}
else
{
DataHolder.getInstance().setVidadd(false);
incomingCall.addCallListener(new SinchVidListner(a));
}
DataHolder.getInstance().setCall(incomingCall);
TextView callState = (TextView) a.findViewById(R.id.fullscreen_content);
callState.setText("Ringing");
button.setText("Answer");
Button dec = (Button) a.findViewById(R.id.Decline) ;
dec.setVisibility(View.VISIBLE);
DataHolder.getInstance().play();
}
}
电话/挂断/接听实施
public void makecall(View v)
{//DataHolder.getInstance().getCall().addCallListener(new SinchCallListener(this));
int type = DataHolder.getInstance().getType();
call=DataHolder.getInstance().getCall() ;
if (call == null) {//make a call
if (type==R.id.next) //when it's a just voice call
{call=sinchClient.getCallClient().callUser(recipientId) ;
call.addCallListener(new SinchCallListener(this));}
else //when it's a Video call
{
call=sinchClient.getCallClient().callUserVideo(recipientId) ;
DataHolder.getInstance().setClient(sinchClient);
call.addCallListener(new SinchVidListner(this));
}
DataHolder.getInstance().setCall(call);
button.setText("Hang Up");
} else if (button.getText()=="Hang Up"){ //hangup
call.hangup();
call=null ;
DataHolder.getInstance().setCall(call) ;
button.setText("Call");
}
else { //answer
DataHolder.getInstance().stop();
call.answer();
if (type==R.id.next) //when it's a just voice call
{call.addCallListener(new SinchCallListener(this));}
else // it's video call
{ DataHolder.getInstance().setClient(sinchClient);
call.addCallListener(new SinchVidListner(this));}
button.setText("Hang Up");
}
}
请随时向我询问进一步的说明,谢谢。
答案 0 :(得分:0)
您需要在视频电台上添加远程视频
{{1}}