Package 

Object StreamMediaDataSource


  • 
    public class StreamMediaDataSource
    
                        

    Centralized provider for Media3 DataSource.Factory instances.

    Wraps the base DefaultDataSource.Factory with CDNDataSourceFactory when a custom CDN is configured, enabling URL rewriting and header injection for media playback (video, audio, voice recordings). When a VideoMediaCache is provided, an on-disk cache layer is composed outside the CDN factory so cached bytes are served without re-signing the URL; misses still go through the CDN.

    • Method Detail

      • factory

         final DataSource.Factory factory(Context context, CDN cdn, VideoMediaCache videoCache)

        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).