Package com.google.android.exoplayer2.source

## Class MaskingMediaSource

- java.lang.Object
- - com.google.android.exoplayer2.source.BaseMediaSource
  - - com.google.android.exoplayer2.source.CompositeMediaSource<Void>
    - - com.google.android.exoplayer2.source.WrappingMediaSource
      - - com.google.android.exoplayer2.source.MaskingMediaSource

- All Implemented Interfaces:
    `MediaSource`

      public final class MaskingMediaSource
      extends WrappingMediaSource

  A `MediaSource` that masks the `Timeline` with a placeholder until the actual media structure is known.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class | Description
    --- | --- | ---
    `static class` | `MaskingMediaSource.PlaceholderTimeline` | A timeline with one dynamic window with a period of indeterminate duration.

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

      `MediaSource.Factory, MediaSource.MediaPeriodId, MediaSource.MediaSourceCaller`

  - ### Field Summary

    - ### Fields inherited from class com.google.android.exoplayer2.source.WrappingMediaSource

      `mediaSource`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `MaskingMediaSource​(MediaSource mediaSource, boolean useLazyPreparation)` | Creates the masking media source.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `MaskingMediaPeriod` | `createPeriod​(MediaSource.MediaPeriodId id, Allocator allocator, long startPositionUs)` | Creates the requested `MediaPeriod`.
    `protected MediaSource.MediaPeriodId` | `getMediaPeriodIdForChildMediaPeriodId​(MediaSource.MediaPeriodId mediaPeriodId)` | Returns the `MediaSource.MediaPeriodId` in the wrapping source corresponding to the specified `MediaSource.MediaPeriodId` in a child source.
    `Timeline` | `getTimeline()` | Returns the `Timeline`.
    `void` | `maybeThrowSourceInfoRefreshError()` | Throws any pending error encountered while loading or refreshing source information.
    `protected void` | `onChildSourceInfoRefreshed​(Timeline newTimeline)` | Called when the child source info has been refreshed.
    `void` | `prepareSourceInternal()` | Starts source preparation and enables the source, see `BaseMediaSource.prepareSource(MediaSourceCaller, TransferListener, PlayerId)`.
    `void` | `releasePeriod​(MediaPeriod mediaPeriod)` | Releases a `MediaPeriod`.
    `void` | `releaseSourceInternal()` | Releases the source, see `BaseMediaSource.releaseSource(MediaSourceCaller)`.

    - ### Methods inherited from class com.google.android.exoplayer2.source.WrappingMediaSource

      `disableChildSource, enableChildSource, getInitialTimeline, getMediaItem, getMediaPeriodIdForChildMediaPeriodId, getMediaTimeForChildMediaTime, getMediaTimeForChildMediaTime, getWindowIndexForChildWindowIndex, getWindowIndexForChildWindowIndex, isSingleWindow, onChildSourceInfoRefreshed, prepareChildSource, prepareSourceInternal, releaseChildSource`

    - ### Methods inherited from class com.google.android.exoplayer2.source.CompositeMediaSource

      `disableChildSource, disableInternal, enableChildSource, enableInternal, prepareChildSource, releaseChildSource`

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

      `addDrmEventListener, addEventListener, createDrmEventDispatcher, createDrmEventDispatcher, createEventDispatcher, createEventDispatcher, createEventDispatcher, disable, enable, getPlayerId, isEnabled, prepareSource, prepareSource, refreshSourceInfo, releaseSource, removeDrmEventListener, removeEventListener`

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

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

- - ### Constructor Detail

    - #### MaskingMediaSource

          public MaskingMediaSource​(MediaSource mediaSource,
                                    boolean useLazyPreparation)

      Creates the masking media source.
      Parameters:
        `mediaSource` - A `MediaSource`.
        `useLazyPreparation` - Whether the `mediaSource` is prepared lazily. If false, all manifest loads and other initial preparation steps happen immediately. If true, these initial preparations are triggered only when the player starts buffering the media.

  - ### Method Detail

    - #### getTimeline

          public Timeline getTimeline()

      Returns the `Timeline`.

    - #### prepareSourceInternal

          public void prepareSourceInternal()

      Description copied from class: `WrappingMediaSource`
      Starts source preparation and enables the source, see `BaseMediaSource.prepareSource(MediaSourceCaller, TransferListener, PlayerId)`. This method is called at most once until the next call to `CompositeMediaSource.releaseSourceInternal()`.
      Overrides:
        `prepareSourceInternal` in class `WrappingMediaSource`

    - #### maybeThrowSourceInfoRefreshError

          public void maybeThrowSourceInfoRefreshError()

      Description copied from interface: `MediaSource`
      Throws any pending error encountered while loading or refreshing source information.

      Should not be called directly from application code.

      Must only be called after `MediaSource.prepareSource(MediaSourceCaller, TransferListener, PlayerId)`.

      Specified by:
        `maybeThrowSourceInfoRefreshError` in interface `MediaSource`
      Overrides:
        `maybeThrowSourceInfoRefreshError` in class `CompositeMediaSource<Void>`

    - #### createPeriod

          public MaskingMediaPeriod createPeriod​(MediaSource.MediaPeriodId id,
                                                 Allocator allocator,
                                                 long startPositionUs)

      Description copied from class: `WrappingMediaSource`
      Creates the requested `MediaPeriod`.

      This method typically forwards to the wrapped media source and optionally wraps the returned `MediaPeriod`.

      Specified by:
        `createPeriod` in interface `MediaSource`
      Overrides:
        `createPeriod` in class `WrappingMediaSource`
      Parameters:
        `id` - The identifier of the period.
        `allocator` - An `Allocator` from which to obtain media buffer allocations.
        `startPositionUs` - The expected start position, in microseconds.
      Returns:
        A new `MediaPeriod`.
      See Also:
        `MediaSource.createPeriod(MediaPeriodId, Allocator, long)`

    - #### releasePeriod

          public void releasePeriod​(MediaPeriod mediaPeriod)

      Description copied from class: `WrappingMediaSource`
      Releases a `MediaPeriod`.

      This method typically forwards to the wrapped media source and optionally unwraps the provided `MediaPeriod`.

      Specified by:
        `releasePeriod` in interface `MediaSource`
      Overrides:
        `releasePeriod` in class `WrappingMediaSource`
      Parameters:
        `mediaPeriod` - The period to release.
      See Also:
        `MediaSource.releasePeriod(MediaPeriod)`

    - #### releaseSourceInternal

          public void releaseSourceInternal()

      Description copied from class: `BaseMediaSource`
      Releases the source, see `BaseMediaSource.releaseSource(MediaSourceCaller)`. This method is called exactly once after each call to `BaseMediaSource.prepareSourceInternal(TransferListener)`.
      Overrides:
        `releaseSourceInternal` in class `CompositeMediaSource<Void>`

    - #### onChildSourceInfoRefreshed

          protected void onChildSourceInfoRefreshed​(Timeline newTimeline)

      Description copied from class: `WrappingMediaSource`
      Called when the child source info has been refreshed.

      This `Timeline` can be amended if needed, for example using `ForwardingTimeline`. The `Timeline` for the wrapping source needs to be published with `BaseMediaSource.refreshSourceInfo(Timeline)`.

      Overrides:
        `onChildSourceInfoRefreshed` in class `WrappingMediaSource`
      Parameters:
        `newTimeline` - The timeline of the child source.

    - #### getMediaPeriodIdForChildMediaPeriodId

          @Nullable
          protected MediaSource.MediaPeriodId getMediaPeriodIdForChildMediaPeriodId​(MediaSource.MediaPeriodId mediaPeriodId)

      Description copied from class: `WrappingMediaSource`
      Returns the `MediaSource.MediaPeriodId` in the wrapping source corresponding to the specified `MediaSource.MediaPeriodId` in a child source. The default implementation does not change the media period id.
      Overrides:
        `getMediaPeriodIdForChildMediaPeriodId` in class `WrappingMediaSource`
      Parameters:
        `mediaPeriodId` - A `MediaSource.MediaPeriodId` of the child source.
      Returns:
        The corresponding `MediaSource.MediaPeriodId` in the wrapping source. Null if no corresponding media period id can be determined.