Skip to content

Add HLS precaching support for Android#1507

Draft
alexgrusu wants to merge 1 commit into
ryanheise:minorfrom
alexgrusu:hls-precaching
Draft

Add HLS precaching support for Android#1507
alexgrusu wants to merge 1 commit into
ryanheise:minorfrom
alexgrusu:hls-precaching

Conversation

@alexgrusu

Copy link
Copy Markdown

This work introduces support for scenarios where we want to precache data and play it directly from the local cache.

To test playback from cache, you have to make this change:

class HlsAudioSource extends UriAudioSource {
  HlsAudioSource(Uri uri,
      {Map<String, String>? headers, dynamic tag, Duration? duration})
      : super(uri, headers: headers, tag: tag, duration: duration);

  @override
  AudioSourceMessage _toMessage() => HlsAudioSourceMessage(
        id: _id,
        // Previously: uri: _effectiveUri.toString(),
        uri: uri.toString(), // Now uses the original (potentially local) URI
        headers: _mergedHeaders,
        tag: tag,
      );
}

With this change, we can use a local file URI when needed, enabling playback from a locally cached file instead of always fetching from a remote URL.

I'm considering a cleaner way to bypass the local URL logic when needed, so suggestions or alternative approaches are welcome!

I'm moving on to implement similar support on the iOS side next.

Please let me know if you find this useful or have any feedback, especially regarding the local URL bypass or improvements for broader platform support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant