Skip to main content

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.

  1. Retrieve the playback URL and license URL (for DRM-protected content) by making a contentAuthorization call, similar to traditional playback.
  2. Build a player instance and keep track of it for later playback.
  3. Register a listener to handle playback state changes.
  4. 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.

  1. Release the previous player before switching content.
  2. Use the player instance that was created during preloading.
  3. Once the player view is available, attach the renderer view.
  4. Wait for LOADED state and call play().
    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 LOADED state.
  • Introduce a short delay (100ms) only if you observe any decoder issue.

Summary

NameAction
Preload ContentFetch content and DRM license URLs → Create Player → Attach Listener → Call load()
Start PlaybackRelease Previous Player → Ensure Renderer Ready → Wait for LOADED State → Call play()