Android Streams Component

General

The Streams are now available for Android!

In this guide, we'll walk you through the basic steps to get started with streaming on Android using the Bitmovin Streams SDK.

πŸ“˜

Benefits of the Android Component

Bitmovin's Streams Android Component simplifies the integration process by dynamically load the Player configuration accordingly the Dashboard configuration and it's properties. With it's simple API, you can iterate quickly while integrating Streams to your Android application without having to worry about native features such as full screen or picture-in-picture.

Getting Started

Step 1: Add the SDK to Your Project

To get started, you'll need to add the Bitmovin Streams SDK to your Android project.

  1. Add the Bitmovin Maven repository to your settings.gradle.kts (or settings.gradle) file:

    dependencyResolutionManagement {
        repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
        repositories {
            mavenCentral()
            maven {
                url = uri("https://artifacts.bitmovin.com/artifactory/public-releases")
            }
            // Other repositories...
        }
    }
    
    dependencyResolutionManagement {
        repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
        repositories {
            mavenCentral()
            maven {
                url "https://artifacts.bitmovin.com/artifactory/public-releases"
            }
            // Other repositories...
        }
    }
    
  2. Include the SDK dependency in your module build.gradle.kts (or build.gradle) file:

    dependencies {
        // Other dependencies...
        implementation("com.bitmovin.streams:streams-android-sdk:<LATEST_VERSION>")
        // Other dependencies...
    }
    
    dependencies {
        // Other dependencies...
        implementation 'com.bitmovin.streams:streams-android-sdk:<LATEST_VERSION>'
        // Other dependencies...
    }
    

Step 2: Update Your Android Manifest

Make sure every activity that may contain streams are configured to support the BitmovinStream component in your AndroidManifest.xml:

<manifest>
    <application>
         <activity
            ...
            android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
            android:resizeableActivity="true"
            android:supportsPictureInPicture="true"
            ... >
        </activity>
    </application>
</manifest>

Step 3: Use the BitmovinStream Component

You're ready to go! You can now use the BitmovinStream component in your Compose-based UI. Here’s a simple example:

// Has to be called from a composable. 
BitmovinStream(
    streamId = "<YOUR-STREAM-ID>"
)
import com.bitmovin.streams.BitmovinStream
...

class YourActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        ...
        enableEdgeToEdge()
        setContent {
            BitmovinStream(
                streamId="<YOUR-STREAM-ID>",
                modifier=Modifier.aspectRatio(16f/9f),
            )
        }
        ...
    }
}

This is the most basic implementation, where you only need to provide the streamId.

🚧

Requirements

The component requires:

  • To be called from a composable function.
  • To be used in Kotlin code as Jetpack Compose is not available for Java.

Component Properties

The BitmovinStream composable function has the following properties:

ParameterDefault ValueDescription
streamIdNoneThe stream id that you want to play. This is the only required property.
modifierModifierThe modifier to be applied to the stream component.
authenticationTokennullThe access token to be used for the stream. Only necessary whenever the stream is protected with a signing key.
autoPlayfalseIf true, the stream will start playing as soon as the component is loaded. Default is true.
mutedfalseIf true, the stream will be muted. Default is false.
loopfalseIf true, the video will repeat itself when the end is reached. It's not recommended on long format videos. Always false when the stream is Live.
posternullThe URL to a preview image displayed until the video starts. The property has the priority over the stream preview image if it is set.
startTime0.0The starting playback of the Stream in seconds.
subtitlesEmpty ListSpecifies an list of external subtitles to be used in the player. The values have to be of the type SubtitleTrack
streamListenernullThe listener for the player events.
enableAdstrueIf true, ads will be enabled.
fullscreenConfigtrueThe configuration for the fullscreen mode.
styleConfigNoneThe style configuration for the player.
allLogsfalseIf true, all logs will be printed. Otherwise, only the warnings and errors will be printed.

There is an alternative way to setup the component using the Configuration class for more flexibility:

ParameterDefault ValueDescription
configNoneThe configuration object you want to pass. Configuration object own all the properties written above aside from the modifier.
modifierModifierThe modifier to be applied to the Stream component.