Stay organized with collections Save and categorize content based on your preferences.

MediaSource.Factory

public interface MediaSource.Factory


Factory for creating MediaSources from MediaItems.

Summary

Constants

default static final MediaSource.Factory

An instance that throws UnsupportedOperationException from createMediaSource and getSupportedTypes.

Public methods

abstract MediaSource

Creates a new MediaSource with the specified MediaItem.

abstract int[]

Returns the content types supported by media sources created by this factory.

abstract MediaSource.Factory

Sets the DrmSessionManagerProvider used to obtain a DrmSessionManager for a MediaItem.

abstract MediaSource.Factory

Sets an optional LoadErrorHandlingPolicy.

Constants

UNSUPPORTED

@UnstableApi
default static final MediaSource.Factory UNSUPPORTED

An instance that throws UnsupportedOperationException from createMediaSource and getSupportedTypes.

Public methods

createMediaSource

@UnstableApi
abstract MediaSource createMediaSource(MediaItem mediaItem)

Creates a new MediaSource with the specified MediaItem.

Parameters
MediaItem mediaItem

The media item to play.

Returns
MediaSource

The new media source.

getSupportedTypes

@UnstableApi
@C.ContentType
abstract int[] getSupportedTypes()

Returns the content types supported by media sources created by this factory.

setDrmSessionManagerProvider

@UnstableApi
abstract MediaSource.Factory setDrmSessionManagerProvider(
    DrmSessionManagerProvider drmSessionManagerProvider
)

Sets the DrmSessionManagerProvider used to obtain a DrmSessionManager for a MediaItem.

Returns
MediaSource.Factory

This factory, for convenience.

setLoadErrorHandlingPolicy

@UnstableApi
abstract MediaSource.Factory setLoadErrorHandlingPolicy(
    LoadErrorHandlingPolicy loadErrorHandlingPolicy
)

Sets an optional LoadErrorHandlingPolicy.

Returns
MediaSource.Factory

This factory, for convenience.