Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

Since Android SDK build 1.0.1.81 it is possible to receive stream publisher events while playing the stream. This can be used to detect if audio or video is muted by stream publisher: when piblisher uses muteAusio()/muteVideo() method, a special event is sending to all the subscribers. To receive this event while playing a stream, define the function Stream.onStreamEvent() and check a value returned by StreamEvent.getType() method:

code

Code Block
languagejava
themeRDark
@Override
public void onStreamEvent(StreamEvent streamEvent) {
    runOnUiThread(new Runnable() {
        @Override
        public void run() {
            switch (streamEvent.getType()) {
                case audioMuted: mAudioMuteStatus.setText(getString(R.string.audio_mute_status)+"true"); break;
                case audioUnmuted: mAudioMuteStatus.setText(getString(R.string.audio_mute_status)+"false"); break;
                case videoMuted: mVideoMuteStatus.setText(getString(R.string.video_mute_status)+"true"); break;
                case videoUnmuted: mVideoMuteStatus.setText(getString(R.string.video_mute_status)+"false");
            }
        }
    });
}

Mixer incoming stream status detection while playing a mixed stream

Since Android SDK build 1.0.1.82 it is possible to detect mixer incoming stream status while playing a mixed stream. In this case, Stream.onStreamEvent() should be defined, in which StreamEvent.payload should be checked with a corresponding method. Then, if payload is not empty, the name of the muted/unmuted stream should be extracted

code

Code Block
languagejava
themeRDark
                @Override
                public void onStreamEvent(StreamEvent streamEvent) {
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            if (streamEvent.getPayload() != null) {
                                mMutedName.setText(getString(R.string.muted_name) + streamEvent.getPayload().getStreamName());
                            }
                            switch (streamEvent.getType()) {
                                case audioMuted: mAudioMuteStatus.setText(getString(R.string.audio_mute_status)+"true"); break;
                                case audioUnmuted: mAudioMuteStatus.setText(getString(R.string.audio_mute_status)+"false"); break;
                                case videoMuted: mVideoMuteStatus.setText(getString(R.string.video_mute_status)+"true"); break;
                                case videoUnmuted: mVideoMuteStatus.setText(getString(R.string.video_mute_status)+"false");
                            }
                        }
                    });
                }