Package com.castlabs.android.player

# Class ErrorMediaSource

java.lang.Object
com.google.android.exoplayer2.source.BaseMediaSource
com.castlabs.android.player.ErrorMediaSource

All Implemented Interfaces:
  `com.google.android.exoplayer2.source.MediaSource`

public class ErrorMediaSource extends com.google.android.exoplayer2.source.BaseMediaSource
`BaseMediaSource` implementation that fails immediately with a predefined error.

- ## Nested Class Summary

  ## Nested classes/interfaces inherited from interface com.google.android.exoplayer2.source.MediaSource

  `com.google.android.exoplayer2.source.MediaSource.Factory, com.google.android.exoplayer2.source.MediaSource.MediaPeriodId, com.google.android.exoplayer2.source.MediaSource.MediaSourceCaller, com.google.android.exoplayer2.source.MediaSource.SourceErrorListener`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ErrorMediaSource(PlayerConfig playerConfig, CastlabsPlayerException error)`
  Creates an error source for the given playlist item.
  `ErrorMediaSource(PlayerConfig playerConfig, IOException error)`
  Creates an error source for the given playlist item.
  `ErrorMediaSource(com.google.android.exoplayer2.MediaItem mediaItem, IOException error)`
  Creates an error source for the given media item.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `com.google.android.exoplayer2.source.MediaPeriod`
  `createPeriod(com.google.android.exoplayer2.source.MediaSource.MediaPeriodId id, com.google.android.exoplayer2.upstream.Allocator allocator, long startPositionUs)`
  `IOException`
  `getError()`
  Returns the error surfaced by this source.
  `com.google.android.exoplayer2.MediaItem`
  `getMediaItem()`
  `PlayerConfig`
  `getPlayerConfig()`
  Returns the playlist item associated with this source.
  `void`
  `maybeThrowSourceInfoRefreshError()`
  `void`
  `releasePeriod(com.google.android.exoplayer2.source.MediaPeriod mediaPeriod)`

  ### Methods inherited from class com.google.android.exoplayer2.source.BaseMediaSource

  `addDrmEventListener, addEventListener, disable, enable, getLiveEdge, getLiveEdge, prepareSource, prepareSource, releaseSource, removeDrmEventListener, removeEventListener`

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

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

  ### Methods inherited from interface com.google.android.exoplayer2.source.MediaSource

  `getInitialTimeline, getLiveSeekOffsetResolved, getLiveSeekOffsetUs, isSingleWindow, setLiveSeekOffsetResolved`

- ## Constructor Details

  - ### ErrorMediaSource

    public ErrorMediaSource(@NonNull PlayerConfig playerConfig, @NonNull IOException error)
    Creates an error source for the given playlist item.
    Parameters:
      `playerConfig` - The associated playlist item.
      `error` - The error to surface through ExoPlayer APIs.

  - ### ErrorMediaSource

    public ErrorMediaSource(@NonNull com.google.android.exoplayer2.MediaItem mediaItem, @NonNull IOException error)
    Creates an error source for the given media item.
    Parameters:
      `mediaItem` - The associated media item.
      `error` - The error to surface through ExoPlayer APIs.

  - ### ErrorMediaSource

    public ErrorMediaSource(@NonNull PlayerConfig playerConfig, @NonNull CastlabsPlayerException error)
    Creates an error source for the given playlist item.
    Parameters:
      `playerConfig` - The associated playlist item.
      `error` - The SDK error to wrap as an `IOException`.

- ## Method Details

  - ### getPlayerConfig

    @Nullable public PlayerConfig getPlayerConfig()
    Returns the playlist item associated with this source.
    Returns:
      The associated playlist item, or `null` if none was provided.

  - ### getError

    @NonNull public IOException getError()
    Returns the error surfaced by this source.
    Returns:
      The error surfaced by this source.

  - ### getMediaItem

    @NonNull public com.google.android.exoplayer2.MediaItem getMediaItem()

  - ### maybeThrowSourceInfoRefreshError

    public void maybeThrowSourceInfoRefreshError() throws IOException
    Throws:
      `IOException`

  - ### createPeriod

    @NonNull public com.google.android.exoplayer2.source.MediaPeriod createPeriod(@NonNull com.google.android.exoplayer2.source.MediaSource.MediaPeriodId id, @NonNull com.google.android.exoplayer2.upstream.Allocator allocator, long startPositionUs)

  - ### releasePeriod

    public void releasePeriod(@NonNull com.google.android.exoplayer2.source.MediaPeriod mediaPeriod)