setSourceUrl method
Sets the URL to a remote link.
The resources will start being fetched or buffered as soon as you call this method.
Implementation
Future<void> setSourceUrl(String url, {String? mimeType}) async {
if (!kIsWeb &&
defaultTargetPlatform != TargetPlatform.android &&
url.startsWith('data:')) {
// Convert data URI's to bytes (native support for web and android).
final uriData = UriData.fromUri(Uri.parse(url));
mimeType ??= url.substring(url.indexOf(':') + 1, url.indexOf(';'));
await setSourceBytes(uriData.contentAsBytes(), mimeType: mimeType);
return;
}
_source = UrlSource(url, mimeType: mimeType);
// Encode remote url to avoid unexpected failures.
await _completePrepared(
() => _platform.setSourceUrl(
playerId,
UriCoder.encodeOnce(url),
mimeType: mimeType,
isLocal: false,
),
);
}