From c767f9cc6225d34fdd34b5d357ffed7f2a081b26 Mon Sep 17 00:00:00 2001 From: Ryan Heise Date: Sun, 4 Oct 2020 13:35:34 +1100 Subject: [PATCH] Fix bug in loading from assets. --- just_audio/lib/just_audio.dart | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/just_audio/lib/just_audio.dart b/just_audio/lib/just_audio.dart index b1dbe2a..f1d426b 100644 --- a/just_audio/lib/just_audio.dart +++ b/just_audio/lib/just_audio.dart @@ -1180,6 +1180,11 @@ abstract class UriAudioSource extends IndexedAudioSource { : _type = type, super(tag); + /// If [uri] points to an asset, this gives us [_overrideUri] which is the URI + /// of the copied asset on the filesystem, otherwise it gives us the original + /// [uri]. + Uri get _effectiveUri => _overrideUri ?? uri; + @override Future _setup(AudioPlayer player) async { await super._setup(player); @@ -1244,7 +1249,7 @@ class ProgressiveAudioSource extends UriAudioSource { @override AudioSourceMessage _toMessage() => ProgressiveAudioSourceMessage( - id: _id, uri: uri.toString(), headers: headers); + id: _id, uri: _effectiveUri.toString(), headers: headers); } /// An [AudioSource] representing a DASH stream. The following URI schemes are @@ -1263,8 +1268,8 @@ class DashAudioSource extends UriAudioSource { : super(uri, headers: headers, tag: tag, type: 'dash'); @override - AudioSourceMessage _toMessage() => - DashAudioSourceMessage(id: _id, uri: uri.toString(), headers: headers); + AudioSourceMessage _toMessage() => DashAudioSourceMessage( + id: _id, uri: _effectiveUri.toString(), headers: headers); } /// An [AudioSource] representing an HLS stream. The following URI schemes are @@ -1282,8 +1287,8 @@ class HlsAudioSource extends UriAudioSource { : super(uri, headers: headers, tag: tag, type: 'hls'); @override - AudioSourceMessage _toMessage() => - HlsAudioSourceMessage(id: _id, uri: uri.toString(), headers: headers); + AudioSourceMessage _toMessage() => HlsAudioSourceMessage( + id: _id, uri: _effectiveUri.toString(), headers: headers); } /// An [AudioSource] representing a concatenation of multiple audio sources to