私は現在Sinch
AndroidSDKを試しているので、現在いくつかの機能を試すためのテストアプリを開発しています。音声アプリからアプリへの通話に成功しましたが、ビデオアプリからアプリへの通話を試行中に問題が発生しました:接続が確立されると、発信者はリモートビデオを表示できますが、受信者はリモートビデオを表示できません(両方とも表示できます)彼らのローカルビデオ)。これが私のコードです:
コールリスナー
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");
}
}
詳細については、お気軽にお問い合わせください。ありがとうございます。
追加されたビデオトラックにリモートビデオを追加する必要があります
@Override
public void onVideoTrackAdded(Call call) {
// Get a reference to your SinchClient, in the samples this is done through the service interface:
VideoController vc = getSinchServiceInterface().getVideoController();
View myPreview = vc.getLocalView();
View remoteView = vc.getRemoteView();
// Add the views to your view hierarchy
...
}
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加