ryanheise / just_audio

Audio Player
1.03k stars 652 forks source link

More efficient asset loading on web #1023

Open ryanheise opened 1 year ago

ryanheise commented 1 year ago

Is your feature request related to a problem? Please describe.

Currently the web implementation needs to encode the asset into a base64 URL which takes processing time on the main isolate.

Describe the solution you'd like

Unlike Flutter for iOS and Android, Flutter for web provides assets as files at a certain URL. I'm not sure if this is guaranteed to not change. For more information:

https://stackoverflow.com/questions/61301598/how-can-i-display-asset-images-on-flutter-web

As long as that holds true, the plugin could just play that URL directly rather than encoding a base64 URL.

Describe alternatives you've considered

If it turns out that the assets directory can't be relied upon, an alternative is to make the current approach more efficient. This would include:

  1. Doing the encoding in a separate isolate
  2. Also eliminating calls to Uri.parse in the web implementation of the platform interface by using String URLs directly.

Additional context

N/A

Dall127 commented 1 year ago

should be helpful: https://github.com/ryanheise/just_audio/issues/1013#issuecomment-1636728734

ryanheise commented 1 year ago

Note, my goal here with asset loading is to bypass data URIs altogether, since the web platform exposes the http/s URis directly.