Package com.google.android.exoplayer2

## Class NoSampleRenderer

- java.lang.Object
- - com.google.android.exoplayer2.NoSampleRenderer

- All Implemented Interfaces:
    `PlayerMessage.Target`, `Renderer`, `RendererCapabilities`

      public abstract class NoSampleRenderer
      extends Object
      implements Renderer, RendererCapabilities

  A `Renderer` implementation whose track type is `C.TRACK_TYPE_NONE` and does not consume data from its `SampleStream`.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface com.google.android.exoplayer2.Renderer

      `Renderer.State, Renderer.VideoScalingMode, Renderer.WakeupListener`

    - ### Nested classes/interfaces inherited from interface com.google.android.exoplayer2.RendererCapabilities

      `RendererCapabilities.AdaptiveSupport, RendererCapabilities.Capabilities, RendererCapabilities.FormatSupport, RendererCapabilities.TunnelingSupport`

  - ### Field Summary

    - ### Fields inherited from interface com.google.android.exoplayer2.Renderer

      `MSG_CUSTOM_BASE, MSG_SET_AUDIO_ATTRIBUTES, MSG_SET_AUDIO_SESSION_ID, MSG_SET_AUX_EFFECT_INFO, MSG_SET_CAMERA_MOTION_LISTENER, MSG_SET_SCALING_MODE, MSG_SET_SKIP_SILENCE_ENABLED, MSG_SET_VIDEO_FRAME_METADATA_LISTENER, MSG_SET_VIDEO_OUTPUT, MSG_SET_VOLUME, MSG_SET_WAKEUP_LISTENER, STATE_DISABLED, STATE_ENABLED, STATE_STARTED, VIDEO_SCALING_MODE_DEFAULT, VIDEO_SCALING_MODE_SCALE_TO_FIT, VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING`

    - ### Fields inherited from interface com.google.android.exoplayer2.RendererCapabilities

      `ADAPTIVE_NOT_SEAMLESS, ADAPTIVE_NOT_SUPPORTED, ADAPTIVE_SEAMLESS, ADAPTIVE_SUPPORT_MASK, FORMAT_EXCEEDS_CAPABILITIES, FORMAT_HANDLED, FORMAT_SUPPORT_MASK, FORMAT_UNSUPPORTED_DRM, FORMAT_UNSUPPORTED_SUBTYPE, FORMAT_UNSUPPORTED_TYPE, TUNNELING_NOT_SUPPORTED, TUNNELING_SUPPORT_MASK, TUNNELING_SUPPORTED`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `NoSampleRenderer()` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `disable()` | Disable the renderer, transitioning it to the `Renderer.STATE_DISABLED` state.
    `void` | `enable​(RendererConfiguration configuration, Format[] formats, SampleStream stream, long positionUs, boolean joining, boolean mayRenderStartOfStream, long startPositionUs, long offsetUs)` | Enables the renderer to consume from the specified `SampleStream`.
    `RendererCapabilities` | `getCapabilities()` | Returns the capabilities of the renderer.
    `protected RendererConfiguration` | `getConfiguration()` | Returns the configuration set when the renderer was most recently enabled, or `null` if the renderer has never been enabled.
    `protected int` | `getIndex()` | Returns the index of the renderer within the player.
    `MediaClock` | `getMediaClock()` | If the renderer advances its own playback position then this method returns a corresponding `MediaClock`.
    `long` | `getReadingPositionUs()` | Returns the renderer time up to which the renderer has read samples, in microseconds, or `C.TIME_END_OF_SOURCE` if the renderer has read the current `SampleStream` to the end.
    `int` | `getState()` | Returns the current state of the renderer.
    `SampleStream` | `getStream()` | Returns the `SampleStream` being consumed, or null if the renderer is disabled.
    `int` | `getTrackType()` | Returns the track type that the renderer handles.
    `void` | `handleMessage​(int messageType, Object message)` | Handles a message delivered to the target.
    `boolean` | `hasReadStreamToEnd()` | Returns whether the renderer has read the current `SampleStream` to the end.
    `boolean` | `isCurrentStreamFinal()` | Returns whether the current `SampleStream` will be the final one supplied before the renderer is next disabled or reset.
    `boolean` | `isEnded()` | Whether the renderer is ready for the `ExoPlayer` instance to transition to `Player.STATE_ENDED`.
    `boolean` | `isReady()` | Whether the renderer is able to immediately render media from the current position.
    `void` | `maybeThrowStreamError()` | Throws an error that's preventing the renderer from reading from its `SampleStream`.
    `protected void` | `onDisabled()` | Called when the renderer is disabled.
    `protected void` | `onEnabled​(boolean joining)` | Called when the renderer is enabled.
    `protected void` | `onPositionReset​(long positionUs, boolean joining)` | Called when the position is reset.
    `protected void` | `onRendererOffsetChanged​(long offsetUs)` | Called when the renderer's offset has been changed.
    `protected void` | `onReset()` | Called when the renderer is reset.
    `protected void` | `onStarted()` | Called when the renderer is started.
    `protected void` | `onStopped()` | Called when the renderer is stopped.
    `void` | `replaceStream​(Format[] formats, SampleStream stream, long startPositionUs, long offsetUs)` | Replaces the `SampleStream` from which samples will be consumed.
    `void` | `reset()` | Forces the renderer to give up any resources (e.g.
    `void` | `resetPosition​(long positionUs)` | Signals to the renderer that a position discontinuity has occurred.
    `void` | `setCurrentStreamFinal()` | Signals to the renderer that the current `SampleStream` will be the final one supplied before it is next disabled or reset.
    `void` | `setIndex​(int index)` | Sets the index of this renderer within the player.
    `void` | `start()` | Starts the renderer, meaning that calls to `Renderer.render(long, long)` will cause media to be rendered.
    `void` | `stop()` | Stops the renderer, transitioning it to the `Renderer.STATE_ENABLED` state.
    `int` | `supportsFormat​(Format format)` | Returns the extent to which the `Renderer` supports a given format.
    `int` | `supportsMixedMimeTypeAdaptation()` | Returns the extent to which the `Renderer` supports adapting between supported formats that have different MIME types.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface com.google.android.exoplayer2.Renderer

      `getName, render, setPlaybackSpeed`

    - ### Methods inherited from interface com.google.android.exoplayer2.RendererCapabilities

      `getName`

- - ### Constructor Detail

    - #### NoSampleRenderer

          public NoSampleRenderer()

  - ### Method Detail

    - #### getTrackType

          public final int getTrackType()

      Description copied from interface: `Renderer`
      Returns the track type that the renderer handles.
      Specified by:
        `getTrackType` in interface `Renderer`
      Specified by:
        `getTrackType` in interface `RendererCapabilities`
      Returns:
        One of the `TRACK_TYPE_*` constants defined in `C`.
      See Also:
        `ExoPlayer.getRendererType(int)`

    - #### getCapabilities

          public final RendererCapabilities getCapabilities()

      Description copied from interface: `Renderer`
      Returns the capabilities of the renderer.
      Specified by:
        `getCapabilities` in interface `Renderer`
      Returns:
        The capabilities of the renderer.

    - #### setIndex

          public final void setIndex​(int index)

      Description copied from interface: `Renderer`
      Sets the index of this renderer within the player.
      Specified by:
        `setIndex` in interface `Renderer`
      Parameters:
        `index` - The renderer index.

    - #### getMediaClock

          @Nullable
          public MediaClock getMediaClock()

      Description copied from interface: `Renderer`
      If the renderer advances its own playback position then this method returns a corresponding `MediaClock`. If provided, the player will use the returned `MediaClock` as its source of time during playback. A player may have at most one renderer that returns a `MediaClock` from this method.
      Specified by:
        `getMediaClock` in interface `Renderer`
      Returns:
        The `MediaClock` tracking the playback position of the renderer, or null.

    - #### getState

          public final int getState()

      Description copied from interface: `Renderer`
      Returns the current state of the renderer.
      Specified by:
        `getState` in interface `Renderer`
      Returns:
        The current state. One of `Renderer.STATE_DISABLED`, `Renderer.STATE_ENABLED` and `Renderer.STATE_STARTED`.

    - #### enable

          public final void enable​(RendererConfiguration configuration,
                                   Format[] formats,
                                   SampleStream stream,
                                   long positionUs,
                                   boolean joining,
                                   boolean mayRenderStartOfStream,
                                   long startPositionUs,
                                   long offsetUs)
                            throws ExoPlaybackException

      Description copied from interface: `Renderer`
      Enables the renderer to consume from the specified `SampleStream`.

      This method may be called when the renderer is in the following states: `Renderer.STATE_DISABLED`.

      Specified by:
        `enable` in interface `Renderer`
      Parameters:
        `configuration` - The renderer configuration.
        `formats` - The enabled formats.
        `stream` - The `SampleStream` from which the renderer should consume.
        `positionUs` - The player's current position.
        `joining` - Whether this renderer is being enabled to join an ongoing playback.
        `mayRenderStartOfStream` - Whether this renderer is allowed to render the start of the stream even if the state is not `Renderer.STATE_STARTED` yet.
        `startPositionUs` - The start position of the stream in renderer time (microseconds).
        `offsetUs` - The offset to be added to timestamps of buffers read from `stream` before they are rendered.
      Throws:
        `ExoPlaybackException` - If an error occurs.

    - #### start

          public final void start()
                           throws ExoPlaybackException

      Description copied from interface: `Renderer`
      Starts the renderer, meaning that calls to `Renderer.render(long, long)` will cause media to be rendered.

      This method may be called when the renderer is in the following states: `Renderer.STATE_ENABLED`.

      Specified by:
        `start` in interface `Renderer`
      Throws:
        `ExoPlaybackException` - If an error occurs.

    - #### replaceStream

          public final void replaceStream​(Format[] formats,
                                          SampleStream stream,
                                          long startPositionUs,
                                          long offsetUs)
                                   throws ExoPlaybackException

      Description copied from interface: `Renderer`
      Replaces the `SampleStream` from which samples will be consumed.

      This method may be called when the renderer is in the following states: `Renderer.STATE_ENABLED`, `Renderer.STATE_STARTED`.

      Specified by:
        `replaceStream` in interface `Renderer`
      Parameters:
        `formats` - The enabled formats.
        `stream` - The `SampleStream` from which the renderer should consume.
        `startPositionUs` - The start position of the new stream in renderer time (microseconds).
        `offsetUs` - The offset to be added to timestamps of buffers read from `stream` before they are rendered.
      Throws:
        `ExoPlaybackException` - If an error occurs.

    - #### getStream

          @Nullable
          public final SampleStream getStream()

      Description copied from interface: `Renderer`
      Returns the `SampleStream` being consumed, or null if the renderer is disabled.
      Specified by:
        `getStream` in interface `Renderer`

    - #### hasReadStreamToEnd

          public final boolean hasReadStreamToEnd()

      Description copied from interface: `Renderer`
      Returns whether the renderer has read the current `SampleStream` to the end.

      This method may be called when the renderer is in the following states: `Renderer.STATE_ENABLED`, `Renderer.STATE_STARTED`.

      Specified by:
        `hasReadStreamToEnd` in interface `Renderer`

    - #### getReadingPositionUs

          public long getReadingPositionUs()

      Description copied from interface: `Renderer`
      Returns the renderer time up to which the renderer has read samples, in microseconds, or `C.TIME_END_OF_SOURCE` if the renderer has read the current `SampleStream` to the end.

      This method may be called when the renderer is in the following states: `Renderer.STATE_ENABLED`, `Renderer.STATE_STARTED`.

      Specified by:
        `getReadingPositionUs` in interface `Renderer`

    - #### setCurrentStreamFinal

          public final void setCurrentStreamFinal()

      Description copied from interface: `Renderer`
      Signals to the renderer that the current `SampleStream` will be the final one supplied before it is next disabled or reset.

      This method may be called when the renderer is in the following states: `Renderer.STATE_ENABLED`, `Renderer.STATE_STARTED`.

      Specified by:
        `setCurrentStreamFinal` in interface `Renderer`

    - #### isCurrentStreamFinal

          public final boolean isCurrentStreamFinal()

      Description copied from interface: `Renderer`
      Returns whether the current `SampleStream` will be the final one supplied before the renderer is next disabled or reset.
      Specified by:
        `isCurrentStreamFinal` in interface `Renderer`

    - #### maybeThrowStreamError

          public final void maybeThrowStreamError()
                                           throws IOException

      Description copied from interface: `Renderer`
      Throws an error that's preventing the renderer from reading from its `SampleStream`. Does nothing if no such error exists.

      This method may be called when the renderer is in the following states: `Renderer.STATE_ENABLED`, `Renderer.STATE_STARTED`.

      Specified by:
        `maybeThrowStreamError` in interface `Renderer`
      Throws:
        `IOException` - An error that's preventing the renderer from making progress or buffering more data.

    - #### resetPosition

          public final void resetPosition​(long positionUs)
                                   throws ExoPlaybackException

      Description copied from interface: `Renderer`
      Signals to the renderer that a position discontinuity has occurred.

      After a position discontinuity, the renderer's `SampleStream` is guaranteed to provide samples starting from a key frame.

      This method may be called when the renderer is in the following states: `Renderer.STATE_ENABLED`, `Renderer.STATE_STARTED`.

      Specified by:
        `resetPosition` in interface `Renderer`
      Parameters:
        `positionUs` - The new playback position in microseconds.
      Throws:
        `ExoPlaybackException` - If an error occurs handling the reset.

    - #### stop

          public final void stop()

      Description copied from interface: `Renderer`
      Stops the renderer, transitioning it to the `Renderer.STATE_ENABLED` state.

      This method may be called when the renderer is in the following states: `Renderer.STATE_STARTED`.

      Specified by:
        `stop` in interface `Renderer`

    - #### disable

          public final void disable()

      Description copied from interface: `Renderer`
      Disable the renderer, transitioning it to the `Renderer.STATE_DISABLED` state.

      This method may be called when the renderer is in the following states: `Renderer.STATE_ENABLED`.

      Specified by:
        `disable` in interface `Renderer`

    - #### reset

          public final void reset()

      Description copied from interface: `Renderer`
      Forces the renderer to give up any resources (e.g. media decoders) that it may be holding. If the renderer is not holding any resources, the call is a no-op.

      This method may be called when the renderer is in the following states: `Renderer.STATE_DISABLED`.

      Specified by:
        `reset` in interface `Renderer`

    - #### isReady

          public boolean isReady()

      Description copied from interface: `Renderer`
      Whether the renderer is able to immediately render media from the current position.

      If the renderer is in the `Renderer.STATE_STARTED` state then returning true indicates that the renderer has everything that it needs to continue playback. Returning false indicates that the player should pause until the renderer is ready.

      If the renderer is in the `Renderer.STATE_ENABLED` state then returning true indicates that the renderer is ready for playback to be started. Returning false indicates that it is not.

      This method may be called when the renderer is in the following states: `Renderer.STATE_ENABLED`, `Renderer.STATE_STARTED`.

      Specified by:
        `isReady` in interface `Renderer`
      Returns:
        Whether the renderer is ready to render media.

    - #### isEnded

          public boolean isEnded()

      Description copied from interface: `Renderer`
      Whether the renderer is ready for the `ExoPlayer` instance to transition to `Player.STATE_ENDED`. The player will make this transition as soon as `true` is returned by all of its renderers.

      This method may be called when the renderer is in the following states: `Renderer.STATE_ENABLED`, `Renderer.STATE_STARTED`.

      Specified by:
        `isEnded` in interface `Renderer`
      Returns:
        Whether the renderer is ready for the player to transition to the ended state.

    - #### supportsFormat

          @Capabilities
          public int supportsFormat​(Format format)
                             throws ExoPlaybackException

      Description copied from interface: `RendererCapabilities`
      Returns the extent to which the `Renderer` supports a given format.
      Specified by:
        `supportsFormat` in interface `RendererCapabilities`
      Parameters:
        `format` - The format.
      Returns:
        The `RendererCapabilities.Capabilities` for this format.
      Throws:
        `ExoPlaybackException` - If an error occurs.

    - #### supportsMixedMimeTypeAdaptation

          @AdaptiveSupport
          public int supportsMixedMimeTypeAdaptation()
                                              throws ExoPlaybackException

      Description copied from interface: `RendererCapabilities`
      Returns the extent to which the `Renderer` supports adapting between supported formats that have different MIME types.
      Specified by:
        `supportsMixedMimeTypeAdaptation` in interface `RendererCapabilities`
      Returns:
        The `RendererCapabilities.AdaptiveSupport` for adapting between supported formats that have different MIME types.
      Throws:
        `ExoPlaybackException` - If an error occurs.

    - #### handleMessage

          public void handleMessage​(int messageType,
                                    @Nullable
                                    Object message)
                             throws ExoPlaybackException

      Description copied from interface: `PlayerMessage.Target`
      Handles a message delivered to the target.
      Specified by:
        `handleMessage` in interface `PlayerMessage.Target`
      Parameters:
        `messageType` - The message type.
        `message` - The message payload.
      Throws:
        `ExoPlaybackException` - If an error occurred whilst handling the message. Should only be thrown by targets that handle messages on the playback thread.

    - #### onEnabled

          protected void onEnabled​(boolean joining)
                            throws ExoPlaybackException

      Called when the renderer is enabled.

      The default implementation is a no-op.

      Parameters:
        `joining` - Whether this renderer is being enabled to join an ongoing playback.
      Throws:
        `ExoPlaybackException` - If an error occurs.

    - #### onRendererOffsetChanged

          protected void onRendererOffsetChanged​(long offsetUs)
                                          throws ExoPlaybackException

      Called when the renderer's offset has been changed.

      The default implementation is a no-op.

      Parameters:
        `offsetUs` - The offset that should be subtracted from `positionUs` in `Renderer.render(long, long)` to get the playback position with respect to the media.
      Throws:
        `ExoPlaybackException` - If an error occurs.

    - #### onPositionReset

          protected void onPositionReset​(long positionUs,
                                         boolean joining)
                                  throws ExoPlaybackException

      Called when the position is reset. This occurs when the renderer is enabled after `onRendererOffsetChanged(long)` has been called, and also when a position discontinuity is encountered.

      The default implementation is a no-op.

      Parameters:
        `positionUs` - The new playback position in microseconds.
        `joining` - Whether this renderer is being enabled to join an ongoing playback.
      Throws:
        `ExoPlaybackException` - If an error occurs.

    - #### onStarted

          protected void onStarted()
                            throws ExoPlaybackException

      Called when the renderer is started.

      The default implementation is a no-op.

      Throws:
        `ExoPlaybackException` - If an error occurs.

    - #### onStopped

          protected void onStopped()

      Called when the renderer is stopped.

      The default implementation is a no-op.

    - #### onDisabled

          protected void onDisabled()

      Called when the renderer is disabled.

      The default implementation is a no-op.

    - #### onReset

          protected void onReset()

      Called when the renderer is reset.

      The default implementation is a no-op.

    - #### getConfiguration

          @Nullable
          protected final RendererConfiguration getConfiguration()

      Returns the configuration set when the renderer was most recently enabled, or `null` if the renderer has never been enabled.

    - #### getIndex

          protected final int getIndex()

      Returns the index of the renderer within the player.