setupRenderer

open override fun setupRenderer(playback: Playback)

Once the Playback finds it is good time for the Playable to request/release the Renderer, it will trigger these calls to send that signal. The 'good time' can varies due to the actual use case. In Kohii, there are 2 following cases:

  • The Playback's Container is also the renderer. In this case, the Container/Renderer will always be there. We suggest that the Playable should request for the Renderer as soon as possible, and release it as late as possible. The proper place to do that are when the Playback becomes active (onActive()) and inactive (onInActive()).

See also

StaticViewRendererPlayback
  • The Playback's Container is not the Renderer. In this case, the Renderer is expected to be created on demand and release as early as possible, so that Kohii can reuse it for other Playback as soon as possible. We suggest that the Playable should request for the Renderer just right before the Playback starts (onPlay()), and release the Renderer just right after the Playback pauses (onPause()).

Flow: Playable#setupRenderer(playback) ↓ If Bridge needs a renderer ↓ Manager#requestRenderer(playback, playable) ↓ Playback#attachRenderer(renderer) ↓ Playback#onAttachRenderer(renderer) ↓ If valid renderer returns, do the update for Bridge

DynamicViewRendererPlayback
DynamicFragmentRendererPlayback