factory

fun factory(context: Context, cdn: CDN?, videoCache: VideoMediaCache? = null): DataSource.Factory

Creates a DataSource.Factory that handles both local and network media URIs.

When a CDN is provided, HTTP/HTTPS requests are transformed through CDN.fileRequest for URL rewriting and header injection. Local URIs (file://, content://) pass through unchanged.

When a videoCache is provided, it wraps the resulting factory so bytes from any ExoPlayer-driven playback (video, audio, voice recordings) are served from disk on subsequent reads. The cache layer is the outermost wrapper, keyed by the dataSpec.uri with query parameters stripped, so cache lookups are unaffected by CDN URL rewriting and by rotating pre-signed query/signature values.

Parameters

context

The context used to create the base data source.

cdn

Optional custom CDN for transforming network requests.

videoCache

Optional disk cache for ExoPlayer-driven playback (video and audio).