Suggestions

close search

Add Messaging, Voice, and Authentication to your apps with Vonage Communications APIs

Visit the Vonage API Developer Portal

Audio Fallback — Android

Use the OpenTok audio fallback API to dynamically prioritize audio in response to network quality.

For conceptual information, see the audio fallback overview.

Notes:

  • The PublisherKit.setAudioFallbackEnabled() and PublisherKit.setAudioFallbackEnabled() methods will be deprecated. Please use the PublisherKit.publisherAudioFallbackEnabled() method instead.

This topic includes the following sections:

Enabling and disabling audio-only fallback

To enable publisher audio fallback, call the PublisherKit.Builder.publisherAudioFallbackEnabled() function when creating the publisher.


// Enable publisher audio fallback
mPublisher = new Publisher.Builder(context)
  .publisherAudioFallbackEnabled(true)
  .build();

// Enable publisher audio fallback and disable subscriber audio fallback
mPublisher = new Publisher.Builder(context)
  .publisherAudioFallbackEnabled(true)
  .subscriberAudioFallbackEnabled(false)
  .build();

// Enable subscriber audio fallback and disable publisher audio fallback
mPublisher = new Publisher.Builder(context)
  .publisherAudioFallbackEnabled(false)
  .subscriberAudioFallbackEnabled(true)
  .build();

To enable and disable subscriber audio fallback (for all subscribers to the stream), call the PublisherKit.Builder.subscriberAudioFallbackEnabled() function when creating the publisher. Subscriber audio fallback is only supported in routed sessions (sessions that use the OpenTok Media Router). Subscriber audio fallback is enabled by default (in routed sessions) for streams with a camera video source.

Publisher audio fallback events

When publisher audio fallback is enabled, callback methods of the PublisherKit.VideoListener are invoked for publisher audio fallback-related events:

For example the following code handles the related events (so that you can provide your own user interface notifications):


@Override
public void onVideoDisableWarning(PublisherKit publisher) {
  // Custom action — for example, add custom UI notification
}

@Override
public void onVideoDisableWarningLifted(PublisherKit publisher) {
  // Custom action — for example, remove custom UI notification
}

@Override
public void onVideoDisabled(PublisherKit publisher, String reason) {
  // Custom action — for example, add custom UI notification
}

@Override
public void onVideoEnabled(PublisherKit subscriber, String reason) {
  // Custom action — for example, remove custom UI notification
}

Subscriber audio fallback events

When subscriber audio fallback is enabled, callback methods of the SubscriberKit.VideoListener are invoked for subscriber audio fallback-related events:

For example the following code handles the related events (so that you can provide your own user interface notifications):


@Override
public void onVideoDisableWarning(SubscriberKit subscriber) {
  // Custom action — for example, add custom UI notification
}

@Override
public void onVideoDisableWarningLifted(SubscriberKit subscriber) {
  // Custom action — for example, remove custom UI notification
}

@Override
public void onVideoDisabled(SubscriberKit subscriber, String reason) {
  // Custom action — for example, add custom UI notification
}

@Override
public void onVideoEnabled(SubscriberKit subscriber, String reason) {
  // Custom action — for example, remove custom UI notification
}