SDK – User Guide
1. Installation
1.1. Gradle setup (typical remote Maven usage)
In a typical setup you will consume the SDK as a binary AAR from a Maven repository:
If you publish the SDK to an internal Maven repository, add it to the repositories section of your Gradle configuration as usual.
Note: In this repository, a local Maven flow is provided for development (
publish-sdk-local.shandlocal-maven-repo/). This is a development detail and not required for external consumers of the SDK.
1.2. Platform requirements
minSdk: 24
targetSdk / compileSdk: 35
Java: 17 (with core library desugaring enabled)
1.3. Example build.gradle for an app using StreaMix SDK
Below is a minimal example of an app module build.gradle configured to use the SDK. Adjust package IDs, versioning and additional dependencies as needed for your project.
Key points:
The SDK pulls in Media3, IMA, Retrofit and other libraries as transitive dependencies – you do not need to declare them manually unless your app directly uses those APIs.
Enabling
coreLibraryDesugaringEnabled truewithdesugar_jdk_libsis recommended when targeting API 24 while using Java 17.The
packaging { resources { excludes += 'META-INF/versions/9/OSGI-INF/MANIFEST.MF' } }block is required: one of the SDK’s transitive dependencies ships as a multi‑release JAR that includes a Java 9‑specific OSGi manifest. This resource is not needed on Android and can cause packaging/merge errors (duplicate or unsupported META‑INF entries), so it must be excluded from the final APK/AAB.You can freely add additional dependencies (RecyclerView, Glide, Leanback, etc.) that your app needs; they do not affect the core StreaMix integration.
2. Core Concepts
Before integrating, it is important to understand the main public classes and interfaces.
2.1. MediaItem
Represents content metadata used by the SDK:
id– content identifier;title– display title;streamUrl– URL of the video stream (e.g. HLS);catId– category identifier;durationSec– duration in seconds;macros– optional map of extra macro values that can be injected into ad/VMAP URLs.
You construct MediaItem instances and pass them to the SDK when starting playback. The macros map can be null if you do not need any custom macro substitutions.
2.2. StreaMixSDK
The main SDK facade and singleton entry point:
holds global configuration and partner/distribution identifiers;
manages internal
StreaMixPlayerinstance;exposes methods to:
initialize the SDK (
initialize(VideoPlayerConfiguration)),bind SDK to your UI (
setupPlayer(...)),control playback (
playMedia(...),pause(),resume(),release()),handle lifecycle (
onActivityPaused(),onActivityResumed()).
Typical call order:
StreaMixSDK.getInstance(...)initialize(VideoPlayerConfiguration)setupPlayer(...)playMedia(...)onActivityPaused()/onActivityResumed()/release()from Activity.
2.3. StreaMixLauncher
A convenience utility for minimal integration:
Init(Context, partnerId, distributionId, applicationName, exoFactory?, imaFactory?)– one‑time initialization.playVideo(Context, MediaItem, boolean adsEnabled)– launches playback in a built‑inPlayerActivityfrom the SDK.playVideo(Context, MediaItem, boolean adsEnabled, PlaybackListener listener)– same as above, but also registers aPlaybackListener…
Use this when you want the fastest path to ad‑enabled playback with minimal custom UI integration.
2.4. PlaybackListener
Callback interface for tracking playback and ad state:
onPlaybackStarted()– content has started playing for the first time;onPlaybackPaused()– content is paused (user/system);onPlaybackResumed()– content resumed after a pause;onPlaybackCompleted()– end of content reached;onAdsStarted()– an ad break has started (including on‑pause ads);onAdsFinished()– the current ad break has finished and content is resuming or has resumed;onPlaybackError(String error)– an error occurred.
Passed to StreaMixSDK.playMedia(MediaItem, PlaybackListener) in advanced integrations. Internally the SDK can fan‑out events to multiple listeners when StreaMixPlayer.addPlaybackListener(...) is used.
2.5. Configuration: VideoPlayerConfiguration and DefaultVideoPlayerConfiguration
VideoPlayerConfiguration defines how ads are configured:
whether ads are enabled;
StreaMixSDK.DefaultVideoPlayerConfiguration is a public builder‑style implementation with common setters:
setAdsEnabled(boolean)
2.6. Factory adapters (advanced)
For advanced control over ExoPlayer and IMA you can implement and pass:
ExoPlayerFactoryAdapter– customize how ExoPlayer is built (track selection, buffering, renderers, etc.).ImaSdkFactoryAdapter– customize how IMA SDK components are created.
These are optional and usually needed only in more complex integrations (see CustomExoDemo / FullDemo).
3. Quick Start – Minimal Integration with StreaMixLauncher
This scenario is best illustrated by the SimpleDemo app. It assumes you are happy to use the SDK’s built‑in PlayerActivity and do not need a custom player UI.
3.1. One‑time SDK initialization
Call StreaMixLauncher.Init(...) once, for example in your Application subclass or in the first Activity:
3.2. Creating a MediaItem
3.3. Starting playback
From any Activity or Fragment:
The SDK will:
open its own
PlayerActivity;initialize ExoPlayer and IMA;
play the specified content with the configured ad schedule.
Lifecycle and UI management are handled internally by the SDK.
4. Standard Integration with StreaMixSDK
When you need more control over the player layout and lifecycle, use StreaMixSDK directly. This scenario corresponds to the FullDemo app (with custom Activity) or intermediate variants like CustomExoDemo.
4.1. Initialize the SDK
Create configuration and get the SDK instance:
Tip: If you rely on remote configuration (via distribution ID), you can attach an
SDKReadyListenerbefore callinginitialize(...)and only begin playback afteronSDKReady().
4.2. Bind SDK to your layout
In your custom Activity layout you typically define:
PlayerViewfor main content;VideoViewfor ads (optional, required for video ads);parent
ViewGroupfor layout management;optional overlay
Viewfor fade animations;optional
ImageViewfor on‑pause image ads.
In your Activity.onCreate() or onResume():
The exact mapping between views and setupPlayer(...) parameters is demonstrated in the FullDemo layout (activity_player_streamix.xml).
4.3. Start playback
Create a MediaItem and call playMedia(...):
4.4. Forward lifecycle events
To keep playback state consistent across Activity lifecycle transitions, forward events to the SDK:
This ensures:
proper handling of on‑pause ads;
correct cleanup of ExoPlayer and IMA resources;
no background leaks when the Activity is destroyed.
5. Configuration and Ads
DefaultVideoPlayerConfiguration controls where the SDK takes its ad configuration from and whether the app/backend can influence how ads are rendered.
5.1. Default behavior (backend-driven configuration)
The SDK contacts the backend and retrieves ad configuration based on the partnerId and distributionId values passed to StreaMixSDK.getInstance(...) or StreaMixLauncher.Init(...).
All scheduling and layout details are defined by the backend.
The ad layout (including side‑by‑side behavior) is controlled by the SDK and backend; the app does not explicitly control the layout in this mode.
5.2. Controlling ads via DefaultVideoPlayerConfiguration
Warning: all ad configuration modes other than backend‑driven configuration (VAST, VMAP, ACF) are experimental and may change or be removed entirely in the release version of the SDK.
Enable / disable ads
If you call setAdsEnabled(false), ads are fully disabled regardless of backend configuration or documents you pass.
6. Error Handling and Logging
6.1. Playback and ads errors
All critical playback and ad errors are surfaced via PlaybackListener.onPlaybackError(String error).
Recommended pattern:
log the error (e.g. to Logcat + your analytics);
optionally show a user‑friendly message;
decide whether to retry, continue without ads, or exit the player.
6.2. Logging
Internally the SDK uses a logging utility (e.g. SdkLogger) and standard Android Log APIs. In debug builds more detailed information is typically available.
For troubleshooting:
enable verbose logs for the host app package and for
com.streamix.sdktags;reproduce the issue and inspect log output around playback/ads events.
7. Best Practices
Start simple: begin with
StreaMixLauncher(SimpleDemo pattern) to verify that your content and ad configuration work, then move to more advanced integrations.Keep lifecycle wired: always forward
onPause()/onResume()/onDestroy()to the SDK.Test on real devices: especially Fire TV vs Android TV, as ad ID and some behaviors differ.
Monitor network conditions: handle transient network issues gracefully using
onPlaybackError()callbacks.Avoid blocking the UI thread: let the SDK perform heavy work (ads, playback) on its own threads; keep your callbacks light.
8. Where to Go Next
For a high‑level conceptual view of the SDK internals, read
SDK_OVERVIEW_EN.mdand the technicalwarp.mddocument.For concrete, end‑to‑end examples based on the demo apps, see
SDK_INTEGRATION_EXAMPLES_EN.md.For API‑level reference, consult the generated JavaDoc for the public classes and interfaces (matching the public API exported via ProGuard rules).

















