audioplayers icon indicating copy to clipboard operation
audioplayers copied to clipboard

Ability to load asset from another asset bundle

Open mehulpamale opened this issue 10 months ago • 2 comments

Checklist

  • [X] I made sure that the issue I am raising doesn't already exist

Use case / Problem

Whilst when adding using asset from another asset bundle general syntax is packages/<package-name>/assets/<actual-path>. The AudioCache is having hardcoded prefix assets/. Although it can be modified using the AudioCache singleton instance, it is not a good idea to modify prefix every-time before loading the asset. Ideally, we should have the ability to pass the prefix in AssetSource.

Proposal / Solution

We should have the ability to pass the prefix in AssetSource.

Example Code

No response

Affected platforms

Android, iOS, web, Windows, Linux, macOS

Platform details

No response

Audio Files/URLs/Sources

No response

Mockups

No response

Related issues / more information

No response

Working on PR

yeah

mehulpamale avatar Oct 18 '23 11:10 mehulpamale

Hey thank you for your proposal. I don't quite get the benefit. I think you can just do:

AudioCache.instance = AudioCache(prefix: '');

And for every new AudioPlayer do:

AudioPlayer().setSource(AssetSource('packages/<package-name>/assets/<actual-path>'));

Providing a prefix in the AssetSource is just like adding the prefix right in front of your uri. I think it doesn't really simplify or reduce the code, one has to write.

See: https://github.com/bluefireteam/audioplayers/blob/main/getting_started.md#audiocache

Gustl22 avatar Oct 26 '23 15:10 Gustl22

In our case we had to do:

AudioCache.instance = AudioCache(prefix: '');
audioPlayer.audioCache = AudioCache.instance;

orestesgaolin avatar Jun 22 '24 20:06 orestesgaolin