Fast channel zapping
Fast Channel Zapping lets you seamlessly switch between streams with minimal startup time for both LIVE and VOD streams. This guide outlines the steps for integration, ensuring efficient playback transitions.
Preload content
Follow these steps to preload content for fast channel zapping.
- Retrieve the playback URL and license URL (for DRM-protected content) by making a contentAuthorization call, similar to traditional playback.
- Build a player instance and keep track of it for later playback.
- Register a listener to handle playback state changes.
- Once the player is initialized, call player.load() to start content preloading.
val playbackPropertiesBuilder = PlaybackProperties.Builder()
playbackPropertiesBuilder.autoPlayOnLoad(false) // By default it's set to false at SDK level.
val playbackProperties = playbackPropertiesBuilder.build()
val playerBuilder = PlayerBuilder()
.mediaURL(contentUrl)
.mediaType(mediaType)
.drmScheme(drmScheme)
.playbackProperties(playbackProperties)
.drmLicenseURL(drmLicenseURL)
val simplePlayer = playerBuilder.build(context)
val player = composablePlayerWith(simplePlayer)
player.addListener(listener)
player.load()
note
Set autoPlayOnLoad to false for pre-loaded content, which is the default value.
Start playback of preloaded content
Follow these steps to start playback of preloaded content.
- Release the previous player before switching content.
- Use the player instance that was created during preloading.
- Once the player view is available, attach the renderer view.
- Wait for
LOADEDstate and callplay().
val renderingContext = VideoRenderingContext(
this@PlayerMultiviewFragment.playerRoot,
FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
)
)
player.attachRendererView(
renderingContext.renderer,
renderingContext.rendererLayoutParams
)
player.play()
Important considerations
Keep these important considerations in mind when implementing fast channel zapping.
- Release the previous player before switching content.
- Attach the renderer only when the player view is available. If the view isn't ready, wait until it's available.
- Playback should only begin when the player is fully loaded - wait for
LOADEDstate. - Introduce a short delay (100ms) only if you observe any decoder issue.
Summary
| Name | Action |
|---|---|
| Preload Content | Fetch content and DRM license URLs → Create Player → Attach Listener → Call load() |
| Start Playback | Release Previous Player → Ensure Renderer Ready → Wait for LOADED State → Call play() |