Class DefaultRenderersFactory

    • Field Detail

      • DEFAULT_ALLOWED_VIDEO_JOINING_TIME_MS

        public static final long DEFAULT_ALLOWED_VIDEO_JOINING_TIME_MS
        The default maximum duration for which a video renderer can attempt to seamlessly join an ongoing playback.
        See Also:
        Constant Field Values
      • EXTENSION_RENDERER_MODE_OFF

        public static final int EXTENSION_RENDERER_MODE_OFF
        Do not allow use of extension renderers.
        See Also:
        Constant Field Values
      • EXTENSION_RENDERER_MODE_ON

        public static final int EXTENSION_RENDERER_MODE_ON
        Allow use of extension renderers. Extension renderers are indexed after core renderers of the same type. A TrackSelector that prefers the first suitable renderer will therefore prefer to use a core renderer to an extension renderer in the case that both are able to play a given track.
        See Also:
        Constant Field Values
      • EXTENSION_RENDERER_MODE_PREFER

        public static final int EXTENSION_RENDERER_MODE_PREFER
        Allow use of extension renderers. Extension renderers are indexed before core renderers of the same type. A TrackSelector that prefers the first suitable renderer will therefore prefer to use an extension renderer to a core renderer in the case that both are able to play a given track.
        See Also:
        Constant Field Values
    • Constructor Detail

      • DefaultRenderersFactory

        public DefaultRenderersFactory​(Context context)
        Parameters:
        context - A Context.
    • Method Detail

      • setExtensionRendererMode

        public DefaultRenderersFactory setExtensionRendererMode​(@com.google.android.exoplayer2.DefaultRenderersFactory.ExtensionRendererMode int extensionRendererMode)
        Sets the extension renderer mode, which determines if and how available extension renderers are used. Note that extensions must be included in the application build for them to be considered available.

        The default value is EXTENSION_RENDERER_MODE_OFF.

        Parameters:
        extensionRendererMode - The extension renderer mode.
        Returns:
        This factory, for convenience.
      • forceEnableMediaCodecAsynchronousQueueing

        public DefaultRenderersFactory forceEnableMediaCodecAsynchronousQueueing()
        Enables MediaCodecRenderer instances to operate their MediaCodec in asynchronous mode and perform asynchronous queueing.

        This feature can be enabled only on devices with API versions >= 23. For devices with older API versions, this method is a no-op.

        Returns:
        This factory, for convenience.
      • forceDisableMediaCodecAsynchronousQueueing

        public DefaultRenderersFactory forceDisableMediaCodecAsynchronousQueueing()
        Disables MediaCodecRenderer instances from operating their MediaCodec in asynchronous mode and perform asynchronous queueing. MediaCodec instances will be operated synchronous mode.
        Returns:
        This factory, for convenience.
      • experimentalSetSynchronizeCodecInteractionsWithQueueingEnabled

        public DefaultRenderersFactory experimentalSetSynchronizeCodecInteractionsWithQueueingEnabled​(boolean enabled)
        Enable synchronizing codec interactions with asynchronous buffer queueing.

        This method is experimental, and will be renamed or removed in a future release.

        Parameters:
        enabled - Whether codec interactions will be synchronized with asynchronous buffer queueing.
        Returns:
        This factory, for convenience.
      • setEnableDecoderFallback

        public DefaultRenderersFactory setEnableDecoderFallback​(boolean enableDecoderFallback)
        Sets whether to enable fallback to lower-priority decoders if decoder initialization fails. This may result in using a decoder that is less efficient or slower than the primary decoder.
        Parameters:
        enableDecoderFallback - Whether to enable fallback to lower-priority decoders if decoder initialization fails.
        Returns:
        This factory, for convenience.
      • setEnableAudioFloatOutput

        public DefaultRenderersFactory setEnableAudioFloatOutput​(boolean enableFloatOutput)
        Sets whether floating point audio should be output when possible.

        Enabling floating point output disables audio processing, but may allow for higher quality audio output.

        The default value is false.

        Parameters:
        enableFloatOutput - Whether to enable use of floating point audio output, if available.
        Returns:
        This factory, for convenience.
      • setEnableAudioOffload

        public DefaultRenderersFactory setEnableAudioOffload​(boolean enableOffload)
        Sets whether audio should be played using the offload path.

        Audio offload disables ExoPlayer audio processing, but significantly reduces the energy consumption of the playback when offload scheduling is enabled.

        Most Android devices can only support one offload AudioTrack at a time and can invalidate it at any time. Thus an app can never be guaranteed that it will be able to play in offload.

        The default value is false.

        Parameters:
        enableOffload - Whether to enable use of audio offload for supported formats, if available.
        Returns:
        This factory, for convenience.
      • setEnableAudioTrackPlaybackParams

        public DefaultRenderersFactory setEnableAudioTrackPlaybackParams​(boolean enableAudioTrackPlaybackParams)
        Sets whether to enable setting playback speed using AudioTrack.setPlaybackParams(PlaybackParams), which is supported from API level 23, rather than using application-level audio speed adjustment. This setting has no effect on builds before API level 23 (application-level speed adjustment will be used in all cases).

        If enabled and supported, new playback speed settings will take effect more quickly because they are applied at the audio mixer, rather than at the point of writing data to the track.

        When using this mode, the maximum supported playback speed is limited by the size of the audio track's buffer. If the requested speed is not supported the player's event listener will be notified twice on setting playback speed, once with the requested speed, then again with the old playback speed reflecting the fact that the requested speed was not supported.

        Parameters:
        enableAudioTrackPlaybackParams - Whether to enable setting playback speed using AudioTrack.setPlaybackParams(PlaybackParams).
        Returns:
        This factory, for convenience.
      • setAllowedVideoJoiningTimeMs

        public DefaultRenderersFactory setAllowedVideoJoiningTimeMs​(long allowedVideoJoiningTimeMs)
        Sets the maximum duration for which video renderers can attempt to seamlessly join an ongoing playback.

        The default value is DEFAULT_ALLOWED_VIDEO_JOINING_TIME_MS.

        Parameters:
        allowedVideoJoiningTimeMs - The maximum duration for which video renderers can attempt to seamlessly join an ongoing playback, in milliseconds.
        Returns:
        This factory, for convenience.
      • buildVideoRenderers

        protected void buildVideoRenderers​(Context context,
                                           @com.google.android.exoplayer2.DefaultRenderersFactory.ExtensionRendererMode int extensionRendererMode,
                                           MediaCodecSelector mediaCodecSelector,
                                           boolean enableDecoderFallback,
                                           Handler eventHandler,
                                           VideoRendererEventListener eventListener,
                                           long allowedVideoJoiningTimeMs,
                                           ArrayList<Renderer> out)
        Builds video renderers for use by the player.
        Parameters:
        context - The Context associated with the player.
        extensionRendererMode - The extension renderer mode.
        mediaCodecSelector - A decoder selector.
        enableDecoderFallback - Whether to enable fallback to lower-priority decoders if decoder initialization fails. This may result in using a decoder that is slower/less efficient than the primary decoder.
        eventHandler - A handler associated with the main thread's looper.
        eventListener - An event listener.
        allowedVideoJoiningTimeMs - The maximum duration for which video renderers can attempt to seamlessly join an ongoing playback, in milliseconds.
        out - An array to which the built renderers should be appended.
      • buildAudioRenderers

        protected void buildAudioRenderers​(Context context,
                                           @com.google.android.exoplayer2.DefaultRenderersFactory.ExtensionRendererMode int extensionRendererMode,
                                           MediaCodecSelector mediaCodecSelector,
                                           boolean enableDecoderFallback,
                                           AudioSink audioSink,
                                           Handler eventHandler,
                                           AudioRendererEventListener eventListener,
                                           ArrayList<Renderer> out)
        Builds audio renderers for use by the player.
        Parameters:
        context - The Context associated with the player.
        extensionRendererMode - The extension renderer mode.
        mediaCodecSelector - A decoder selector.
        enableDecoderFallback - Whether to enable fallback to lower-priority decoders if decoder initialization fails. This may result in using a decoder that is slower/less efficient than the primary decoder.
        audioSink - A sink to which the renderers will output.
        eventHandler - A handler to use when invoking event listeners and outputs.
        eventListener - An event listener.
        out - An array to which the built renderers should be appended.
      • buildTextRenderers

        protected void buildTextRenderers​(Context context,
                                          TextOutput output,
                                          Looper outputLooper,
                                          @com.google.android.exoplayer2.DefaultRenderersFactory.ExtensionRendererMode int extensionRendererMode,
                                          ArrayList<Renderer> out)
        Builds text renderers for use by the player.
        Parameters:
        context - The Context associated with the player.
        output - An output for the renderers.
        outputLooper - The looper associated with the thread on which the output should be called.
        extensionRendererMode - The extension renderer mode.
        out - An array to which the built renderers should be appended.
      • buildMetadataRenderers

        protected void buildMetadataRenderers​(Context context,
                                              MetadataOutput output,
                                              Looper outputLooper,
                                              @com.google.android.exoplayer2.DefaultRenderersFactory.ExtensionRendererMode int extensionRendererMode,
                                              ArrayList<Renderer> out)
        Builds metadata renderers for use by the player.
        Parameters:
        context - The Context associated with the player.
        output - An output for the renderers.
        outputLooper - The looper associated with the thread on which the output should be called.
        extensionRendererMode - The extension renderer mode.
        out - An array to which the built renderers should be appended.
      • buildCameraMotionRenderers

        protected void buildCameraMotionRenderers​(Context context,
                                                  @com.google.android.exoplayer2.DefaultRenderersFactory.ExtensionRendererMode int extensionRendererMode,
                                                  ArrayList<Renderer> out)
        Builds camera motion renderers for use by the player.
        Parameters:
        context - The Context associated with the player.
        extensionRendererMode - The extension renderer mode.
        out - An array to which the built renderers should be appended.
      • buildMiscellaneousRenderers

        protected void buildMiscellaneousRenderers​(Context context,
                                                   Handler eventHandler,
                                                   @com.google.android.exoplayer2.DefaultRenderersFactory.ExtensionRendererMode int extensionRendererMode,
                                                   ArrayList<Renderer> out)
        Builds any miscellaneous renderers used by the player.
        Parameters:
        context - The Context associated with the player.
        eventHandler - A handler to use when invoking event listeners and outputs.
        extensionRendererMode - The extension renderer mode.
        out - An array to which the built renderers should be appended.