setSourceAsset method

Future<void> setSourceAsset(
  1. String path, {
  2. String? mimeType,
})

Sets the URL to an asset in your Flutter application. The global instance of AudioCache will be used by default.

The resources will start being fetched or buffered as soon as you call this method.

Implementation

Future<void> setSourceAsset(String path, {String? mimeType}) async {
  _source = AssetSource(path, mimeType: mimeType);
  final cachePath = await audioCache.loadPath(path);
  await _completePrepared(
    () => _platform.setSourceUrl(
      playerId,
      cachePath,
      mimeType: mimeType,
      isLocal: true,
    ),
  );
}