예제 #1
0
 @Override
 public void onMessage(PnPeer peer, Object message) {
   super.onMessage(peer, message); // Will log values
   if (!(message instanceof JSONObject)) return; // Ignore if not JSONObject
   JSONObject jsonMsg = (JSONObject) message;
   try {
     if (jsonMsg.has(IOIOCommands.IOIO_CONTROL_MSG)) {
       mService.setIOIOCommand(jsonMsg.getString(IOIOCommands.IOIO_CONTROL_MSG));
     }
   } catch (JSONException e) {
     e.printStackTrace();
   }
 }
예제 #2
0
 @Override
 public void onLocalStream(final MediaStream localStream) {
   super.onLocalStream(localStream); // Will log values
   VideoChatActivity.this.runOnUiThread(
       new Runnable() {
         @Override
         public void run() {
           if (localStream.videoTracks.size() == 0) return;
           localStream.videoTracks.get(0).addRenderer(new VideoRenderer(localRender));
           mCallStatus.setVisibility(View.GONE);
         }
       });
 }
예제 #3
0
 @Override
 public void onPeerConnectionClosed(PnPeer peer) {
   super.onPeerConnectionClosed(peer);
   VideoChatActivity.this.runOnUiThread(
       new Runnable() {
         @Override
         public void run() {
           mCallStatus.setText("Call Ended...");
           mCallStatus.setVisibility(View.VISIBLE);
         }
       });
   try {
     Thread.sleep(1500);
   } catch (InterruptedException e) {
     e.printStackTrace();
   }
   Intent intent = new Intent(VideoChatActivity.this, QBotActivity.class);
   startActivity(intent);
   finish();
 }
예제 #4
0
 @Override
 public void onAddRemoteStream(final MediaStream remoteStream, final PnPeer peer) {
   super.onAddRemoteStream(remoteStream, peer); // Will log values
   VideoChatActivity.this.runOnUiThread(
       new Runnable() {
         @Override
         public void run() {
           Toast.makeText(
                   VideoChatActivity.this, "Connected to " + peer.getId(), Toast.LENGTH_SHORT)
               .show();
           try {
             if (remoteStream.audioTracks.size() == 0 || remoteStream.videoTracks.size() == 0)
               return;
             mCallStatus.setVisibility(View.GONE);
             remoteStream.videoTracks.get(0).addRenderer(new VideoRenderer(remoteRender));
             VideoRendererGui.update(
                 remoteRender,
                 0,
                 0,
                 100,
                 100,
                 VideoRendererGui.ScalingType.SCALE_ASPECT_FILL,
                 false);
             VideoRendererGui.update(
                 localRender,
                 72,
                 65,
                 25,
                 25,
                 VideoRendererGui.ScalingType.SCALE_ASPECT_FIT,
                 true);
           } catch (Exception e) {
             e.printStackTrace();
           }
         }
       });
 }