Control live streams with GoCoder SDK for Android

Learn how to start, stop, and monitor a live stream broadcast with Wowza GoCoder™ SDK for Android.

Before you begin

Before adding the functionality below to your app, make sure you've set up the Wowza GoCoder SDK for your project:

  • Request a free license and download the latest version of the SDK.
  • Configure your Android Studio project to use the SDK.

See Download and install GoCoder SDK for Android for detailed instructions.

Start streaming

Use the startStreaming method in the WowzaGoCoder class to start a live stream.

//Make sure streaming isn't already active
if (!this.goCoder.isStreaming()) {
  // Validate the current broadcast config
  WOWZStreamingError configValidationError = this.goCoder.getConfig().validateForBroadcast();
  if (configValidationError != null) {
  } else {
    // Start the live stream

Note: If you start a broadcast and logs record a "Decreasing bitrate to..." message, it means you're using a bitrate that's too large for the current network conditions. The broadcaster will start buffering frames to preserve the quality of the playback and any recordings, but this will increase playback latency. To minimize latency, try using a lower bitrate instead.

Stop streaming

Use the endStreaming method in the WowzaGoCoder class to stop a live stream.

if (this.goCoder.isStreaming()) {
  // Stop the live stream

Monitor the status of the live stream

Use the statusCallback argument for the startStreaming and endStreaming methods to implement the WOWZStatusCallback interface. This interface defines the following callbacks that are invoked for a live stream broadcast:

Status Description
WOWZState.IDLE The stream is inactive. This is the status before and after the broadcast.
WOWZState.STARTING The audio and video inputs are initializing and the stream is connecting to a Wowza Streaming Engine server or the Wowza Streaming Cloud live stream.
WOWZState.READY The audio, video, and stream connection are successfully initialized.
WOWZState.RUNNING The broadcast is actively streaming.
WOWZState.STOPPING The streaming connection is closing. After the connection closes, the broadcast status returns to WOWZState.IDLE.

The following example shows successful status transitions and an error status:

// Methods implemented for the WOWZStatusCallback interface

// A successful status transition has been reported by the GoCoder SDK  
WOWZStatusCallback statusCallback = new WOWZStatusCallback() {
  public void onSuccess(final WOWZStatus goCoderStatus) {
    switch (state) {
      case WOWZState.IDLE:, "Streaming is not active");

      case WOWZState.STARTING:, "Broadcast initialization");

      case WOWZState.READY:, "Ready to begin streaming");

      case WOWZState.RUNNING:, "Streaming is active");

      case WOWZState.STOPPING:, "Broadcast shutdown");

  // If an error is reported by the GoCoder SDK, display a toast message containing the details   
  public void onError(final WOWZStatus goCoderStatus) {
    // Run this on the U/I thread
    new Handler(Looper.getMainLooper()).post(new Runnable() {
      public void run() {
        Toast.setText("Live Streaming Error: " + goCoderStatus.getLastError().getErrorDescription(), LENGTH_LONG).show();

// Begin streaming

More resources