Interface MediaSource

    • Method Detail

      • addEventListener

        void addEventListener​(Handler handler,
                              MediaSourceEventListener eventListener)
        Adds a MediaSourceEventListener to the list of listeners which are notified of media source events.
        Parameters:
        handler - A handler on the which listener events will be posted.
        eventListener - The listener to be added.
      • removeEventListener

        void removeEventListener​(MediaSourceEventListener eventListener)
        Removes a MediaSourceEventListener from the list of listeners which are notified of media source events.
        Parameters:
        eventListener - The listener to be removed.
      • addDrmEventListener

        void addDrmEventListener​(Handler handler,
                                 DrmSessionEventListener eventListener)
        Adds a DrmSessionEventListener to the list of listeners which are notified of DRM events for this media source.
        Parameters:
        handler - A handler on the which listener events will be posted.
        eventListener - The listener to be added.
      • removeDrmEventListener

        void removeDrmEventListener​(DrmSessionEventListener eventListener)
        Removes a DrmSessionEventListener from the list of listeners which are notified of DRM events for this media source.
        Parameters:
        eventListener - The listener to be removed.
      • getInitialTimeline

        @Nullable
        default Timeline getInitialTimeline()
        Returns the initial placeholder timeline that is returned immediately when the real timeline is not yet known, or null to let the player create an initial timeline.

        The initial timeline must use the same uids for windows and periods that the real timeline will use. It also must provide windows which are marked as dynamic to indicate that the window is expected to change when the real timeline arrives.

        Any media source which has multiple windows should typically provide such an initial timeline to make sure the player reports the correct number of windows immediately.

      • isSingleWindow

        default boolean isSingleWindow()
        Returns true if the media source is guaranteed to never have zero or more than one window.

        The default implementation returns true.

        Returns:
        true if the source has exactly one window.
      • getMediaItem

        MediaItem getMediaItem()
        Returns the MediaItem whose media is provided by the source.
      • createPeriod

        MediaPeriod createPeriod​(MediaSource.MediaPeriodId id,
                                 Allocator allocator,
                                 long startPositionUs)
        Returns a new MediaPeriod identified by periodId.

        Should not be called directly from application code.

        Must only be called if the source is enabled.

        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.
      • releasePeriod

        void releasePeriod​(MediaPeriod mediaPeriod)
        Releases the period.

        Should not be called directly from application code.

        Parameters:
        mediaPeriod - The period to release.