just_audio icon indicating copy to clipboard operation
just_audio copied to clipboard

Feature Request: Support more audio file formats

Open rohansohonee opened this issue 5 years ago • 12 comments

Since the migration to exoplayer I think supporting all the various audio file formats should be done. Currently in my testing I discovered that .flac files do not play. I had been only testing using .mp3 this whole time. Hope support for all audio formats can be added in future updates.

rohansohonee avatar Jan 01 '20 05:01 rohansohonee

Some of my research notes for iOS:

sachaarbonel avatar Jul 07 '20 12:07 sachaarbonel

Flac work but something got this kind of errors on Android:

2
W/DefaultLoadControl(12906): Target buffer size reached with less than 500ms of buffered media data.
E/ExoPlayerImplInternal(12906): Playback error
E/ExoPlayerImplInternal(12906):   com.google.android.exoplayer2.ExoPlaybackException: Unexpected runtime error
E/ExoPlayerImplInternal(12906):       at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:608)
E/ExoPlayerImplInternal(12906):       at android.os.Handler.dispatchMessage(Handler.java:103)
E/ExoPlayerImplInternal(12906):       at android.os.Looper.loop(Looper.java:214)
E/ExoPlayerImplInternal(12906):       at android.os.HandlerThread.run(HandlerThread.java:67)
E/ExoPlayerImplInternal(12906):   Caused by: java.lang.IllegalStateException: Playback stuck buffering and not loading
E/ExoPlayerImplInternal(12906):       at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:1046)
E/ExoPlayerImplInternal(12906):       at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:482)
E/ExoPlayerImplInternal(12906):       ... 3 more
E/AudioPlayer(12906): TYPE_UNEXPECTED: Playback stuck buffering and not loading

But when I use the same with mp3 everything works fine.

Kiruel avatar May 09 '22 13:05 Kiruel

I think in the time since this feature request was made, ExoPlayer (the underlying Android library from Google that provides the Android audio playing capabilities) has undergone a lot of improvements. But if FLAC has any issue still, I think it's due to the FLAC support from ExoPlayer itself. You could try submitting a bug report with ExoPlayer with that specific FLAC file. In terms of a minimal reproduction project, I think they have an official example and you can just switch in your FLAC file for one of the existing MP3 URLs in that sample code.

ryanheise avatar May 09 '22 14:05 ryanheise

Alright thanks, I will investigate on the ExoPlayer itself.

Kiruel avatar May 09 '22 14:05 Kiruel

I just test the Flac demo on the Exoplayer, and the buffering was OK. I think it's probably because the just_audio is on 2.15.0.

I will try to use the lastest version of ExoPlayer the 2.17.1 https://mvnrepository.com/artifact/com.google.android.exoplayer/exoplayer

Kiruel avatar May 09 '22 14:05 Kiruel

Sounds like a plan. Please let me know how it goes, and if it solves the FLAC problem, I'll update the plugin's version.

ryanheise avatar May 09 '22 14:05 ryanheise

I will fill a PR if it's fix. I will let you know if it's not ;) !

Kiruel avatar May 09 '22 14:05 Kiruel

Seems to be more complicated than I think. Got a lot of deprecation, and 2 failures when trying to run the example/android. I will need more time to configure the project to be able to debug it. Can you try to upgrade to 2.17.1 in your side ?

Kiruel avatar May 09 '22 14:05 Kiruel

That's fine. If it involves changes to the code, leave it to me and I'll upgrade everything.

ryanheise avatar May 09 '22 14:05 ryanheise

So I will let you change the version ;) !

Kiruel avatar May 11 '22 13:05 Kiruel

Just to update, I have migrated to ExoPlayer 2.17.1 in the latest commit on branch fix/flutter3. Note that this version of ExoPlayer contains enough methods that you'll probably get a trigger to use multidex.

ryanheise avatar May 27 '22 17:05 ryanheise

That branch has now been merged and published to pub.dev.

ryanheise avatar May 28 '22 12:05 ryanheise