Initiating YouTube Live Streams on Android Devices

Stay organized with collections Save and categorize content based on your preferences.

The YouTube Mobile Live deep link enables Android applications to initiate a YouTube live stream directly from a mobile device. An app only needs to provide an entry point, such as a button that the user can click, that starts the Mobile Live flow via the Android Intent mechanism.

Example

This flow shows the user experience for an app that deep links into the YouTube application, where the user lands on the Mobile Live Stream Setup screen.

  1. First, the user configures the stream, setting the title, privacy mode, and other stream options.
  2. Then, the user navigates to the Thumbnail Photo screen to set a thumbnail image for the stream.
  3. Finally, the user starts the live stream and broadcasts the view from the front or rear camera.

Device Requirements

Android devices must meet the following requirements to properly support YouTube live streaming and the Mobile Live deep link:

  • Android release: Marshmallow (API 23) or higher
  • Camera: At least one camera capable of recording 720p at at least 30Hz
  • Microphone: Onboard microphone
  • Audio encoder: Hardware accelerated audio encoder capable of encoding 8-bit PCM mono audio to AAC at 44.1KHz or better
  • Video encoder: Hardware accelerated video encoder capable of encoding 720P raw video to H.264/AVC at 30Hz or better
  • YouTube app installed: Version 13.02 or higher

Mobile Live Intent specification

To link into the YouTube Mobile live streaming flow, your Android app launches an Intent. The Intent initiates the live streaming process by starting an Activity in the YouTube application.

Intent format

The Mobile Live Intent uses a custom Action string to navigate to the live creation Activity within the YouTube app. It also specifies the package name for the YouTube mobile app.

  • Action: “com.google.android.youtube.intent.action.CREATE_LIVE_STREAM
  • Package: "com.google.android.youtube"

Intent extras

The YouTube application setup flow handles the stream configuration. The following Intent extras set parameters associated with the live stream:

Params
Intent.EXTRA_REFERRER Required. This parameter specifies a URI that represents the application launching the live streaming Activity. This value must follow the android-app: scheme format with a package name. The value enables accurate attribution and accounting.
Intent.EXTRA_SUBJECT Optional. This parameter provides a text description of the live stream. It is placed in the Intent extras bundle as a String. The value can be used to annotate the stream with a branded message, such as "Streamed live from DEVICE".

Launching the live streaming flow

Step 1: Check for support

Your client should first confirm that the Mobile Live Intent can be launched by verifying that the YouTube app is installed on the device and that the YouTube app version supports live streaming. The following code sample defines two methods to do that:

  • The canResolveMobileLiveIntent method verifies that the device supports the Mobile Live Intent.
  • The validateMobileLiveIntent calls the canResolveMobileLiveIntent method in the context of an if-else statement.
    • If the device supports the Intent, then the device could launch the live stream flow.
    • If the device does not support the Intent, then the device could prompt the user to install or upgrade the YouTube app.
private boolean canResolveMobileLiveIntent(Context context) {
  Intent intent = new Intent("com.google.android.youtube.intent.action.CREATE_LIVE_STREAM")
    .setPackage("com.google.android.youtube");
  PackageManager pm = context.getPackageManager();
  List resolveInfo = 
    pm.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
  return resolveInfo != null && !resolveInfo.isEmpty();
}


private void validateMobileLiveIntent(Context context) {
  if (canResolveMobileLiveIntent(context)) {
    // Launch the live stream Activity
  } else {
    // Prompt user to install or upgrade the YouTube app
  }
}

Step 2: Launch the live stream activity

To start the live streaming flow, your client app creates and launches an Intent as shown in the following code sample:

private Intent createMobileLiveIntent(Context context, String description) {
  Intent intent = new Intent("com.google.android.youtube.intent.action.CREATE_LIVE_STREAM")
      .setPackage("com.google.android.youtube");
  Uri referrer = new Uri.Builder()
      .scheme("android-app")
      .appendPath(context.getPackageName())
      .build();

  intent.putExtra(Intent.EXTRA_REFERRER, referrer);
  if (!TextUtils.isEmpty(description)) {
    intent.putExtra(Intent.EXTRA_SUBJECT, description);
  }
  return intent;
}


private void startMobileLive(Context context) {
  Intent mobileLiveIntent = createMobileLiveIntent(context, "Streaming via ...");
  startActivity(mobileLiveIntent);
}