Fix bug in loading from assets.

This commit is contained in:
Ryan Heise 2020-10-04 13:35:34 +11:00
parent 35a6e4810b
commit c767f9cc62
1 changed files with 10 additions and 5 deletions

View File

@ -1180,6 +1180,11 @@ abstract class UriAudioSource extends IndexedAudioSource {
: _type = type, : _type = type,
super(tag); 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 @override
Future<void> _setup(AudioPlayer player) async { Future<void> _setup(AudioPlayer player) async {
await super._setup(player); await super._setup(player);
@ -1244,7 +1249,7 @@ class ProgressiveAudioSource extends UriAudioSource {
@override @override
AudioSourceMessage _toMessage() => ProgressiveAudioSourceMessage( 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 /// 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'); : super(uri, headers: headers, tag: tag, type: 'dash');
@override @override
AudioSourceMessage _toMessage() => AudioSourceMessage _toMessage() => DashAudioSourceMessage(
DashAudioSourceMessage(id: _id, uri: uri.toString(), headers: headers); id: _id, uri: _effectiveUri.toString(), headers: headers);
} }
/// An [AudioSource] representing an HLS stream. The following URI schemes are /// 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'); : super(uri, headers: headers, tag: tag, type: 'hls');
@override @override
AudioSourceMessage _toMessage() => AudioSourceMessage _toMessage() => HlsAudioSourceMessage(
HlsAudioSourceMessage(id: _id, uri: uri.toString(), headers: headers); id: _id, uri: _effectiveUri.toString(), headers: headers);
} }
/// An [AudioSource] representing a concatenation of multiple audio sources to /// An [AudioSource] representing a concatenation of multiple audio sources to