Toggle Video and Audio in Android App

Hi,
This is a silly question but I could not find the answer in the docs. :frowning:

So, I have a android app (clone of openvidu’s GitHub android app) which I have successfully connected to my own server. I wanted to toggle audio and video and recv chat messages in the android app, but I could not find the answer in the docs.

How do we toggle video audio and recv chat in an Android app?
Thanks

Android sample app is a prototype, is not a proper SDK. For that reason, is not supported neither documented.

You will have to take a look to the source code and find yourself.

Maybe some community member can help you.

Regards

Hello Arush,

To receive chat messages is actually quite easy, you need to add the code to intercept the message in the handleServerEvent function here:

https://github.com/OpenVidu/openvidu-tutorials/blob/a569a8598495a475c68ff0452a82ee3a9adb7775/openvidu-android/app/src/main/java/io/openvidu/openvidu_android/websocket/CustomWebSocket.java#L215

So basically you need to add another switch case:

case JsonConstants.SEND_MESSAGE:
     Log.e(TAG, "Send Message " + json.toString());
break;

This constant was declared in JsonConstants.java file like this:

public static final String SEND_MESSAGE = "sendMessage";

You will be able to parse the JSON payload which has this format:

{
  "method": "sendMessage",
  "params": {
    "data": "test chat",
    "type": "signal:chat",
    "from": "con_FVGC0ckCzr"
  },
  "jsonrpc": "2.0"
}

For your other issue with disabling/enabling audio/video I can only suggest you to remove/add the audio/video tracks from/to the media stream. I can’t help you with code as mobile apps development is not my expertise.

Regards,
Mihail

1 Like

Never mind, I have decided to use ionic :slight_smile: