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.
-
Add the Bitmovin Maven repository to your
settings.gradle.kts
(orsettings.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... } }
-
Include the SDK dependency in your module
build.gradle.kts
(orbuild.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:
Parameter | Default Value | Description |
---|---|---|
streamId | None | The stream id that you want to play. This is the only required property. |
modifier | Modifier | The modifier to be applied to the stream component. |
authenticationToken | null | The access token to be used for the stream. Only necessary whenever the stream is protected with a signing key. |
autoPlay | false | If true, the stream will start playing as soon as the component is loaded. Default is true. |
muted | false | If true, the stream will be muted. Default is false. |
loop | false | If 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. |
poster | null | The URL to a preview image displayed until the video starts. The property has the priority over the stream preview image if it is set. |
startTime | 0.0 | The starting playback of the Stream in seconds. |
subtitles | Empty List | Specifies an list of external subtitles to be used in the player. The values have to be of the type SubtitleTrack |
streamListener | null | The listener for the player events. |
enableAds | true | If true, ads will be enabled. |
fullscreenConfig | true | The configuration for the fullscreen mode. |
styleConfig | None | The style configuration for the player. |
allLogs | false | If 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:
Parameter | Default Value | Description |
---|---|---|
config | None | The configuration object you want to pass. Configuration object own all the properties written above aside from the modifier. |
modifier | Modifier | The modifier to be applied to the Stream component. |
Updated 4 months ago