ryanheise / just_audio

Audio Player
1.05k stars 677 forks source link

⭐Please upgrade ExoPlayer to the latest version⭐ #814

Closed zhushenwudi closed 2 years ago

zhushenwudi commented 2 years ago

Which API doesn't behave as documented, and how does it misbehave? api: v0.9.28 Some songs will report errors when playing When I tried another open source project: https://github.com/OxygenCobalt/Auxio I found that the latest version of exoplayer did not report an error It only exists on Android devices

Minimal reproduction project Provide a link here using one of two options:

  1. use a sample code by just_audio
  2. play https://drive.google.com/file/d/1McjOG8bgsu1nX8kF1oHbzgIOT8xAEYB2/view?usp=sharing

To Reproduce (i.e. user steps, not code) Steps to reproduce the behavior:

  1. play
  2. see error

Error messages

E/MediaCodecAudioRenderer: Audio codec error
java.lang.IllegalStateException
at android.media.MediaCodec.native_dequeueInputBuffer(Native Method)
at android.media.MediaCodec.dequeueInputBuffer(MediaCodec.java:2855)
at com.google.android.exoplayer2.mediacodec.SynchronousMediaCodecAdapter.dequeueInputBufferIndex(SynchronousMediaCodecAdapter.java:99)
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.feedInputBuffer(MediaCodecRenderer.java:1177)
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:794)
at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:998)
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:499)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:223)
at android.os.HandlerThread.run(HandlerThread.java:67)
E/ExoPlayerImplInternal: Playback error
com.google.android.exoplayer2.ExoPlaybackException: MediaCodecAudioRenderer error, index=1, format=Format(null, null, null, audio/flac, null, -1, null, [-1, -1, -1.0], [2, 44100]), format_supported=YES
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:575)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:223)
at android.os.HandlerThread.run(HandlerThread.java:67)
Caused by: com.google.android.exoplayer2.mediacodec.MediaCodecDecoderException: Decoder failed: c2.android.flac.decoder
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.createDecoderException(MediaCodecRenderer.java:932)
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:813)
at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:998)
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:499)
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:223) 
at android.os.HandlerThread.run(HandlerThread.java:67) 
Caused by: java.lang.IllegalStateException
at android.media.MediaCodec.native_dequeueInputBuffer(Native Method)
at android.media.MediaCodec.dequeueInputBuffer(MediaCodec.java:2855)
at com.google.android.exoplayer2.mediacodec.SynchronousMediaCodecAdapter.dequeueInputBufferIndex(SynchronousMediaCodecAdapter.java:99)
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.feedInputBuffer(MediaCodecRenderer.java:1177)
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:794)
at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:998) 
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:499) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:223) 
at android.os.HandlerThread.run(HandlerThread.java:67) 
E/ExoPlayerImplInternal: Disable failed.
java.lang.IllegalStateException
at android.media.MediaCodec.native_flush(Native Method)
at android.media.MediaCodec.flush(MediaCodec.java:2298)
at com.google.android.exoplayer2.mediacodec.SynchronousMediaCodecAdapter.flush(SynchronousMediaCodecAdapter.java:166)
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.flushCodec(MediaCodecRenderer.java:864)
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.flushOrReleaseCodec(MediaCodecRenderer.java:857)
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.onDisabled(MediaCodecRenderer.java:710)
at com.google.android.exoplayer2.audio.MediaCodecAudioRenderer.onDisabled(MediaCodecAudioRenderer.java:603)
at com.google.android.exoplayer2.BaseRenderer.disable(BaseRenderer.java:186)
at com.google.android.exoplayer2.ExoPlayerImplInternal.disableRenderer(ExoPlayerImplInternal.java:1671)
at com.google.android.exoplayer2.ExoPlayerImplInternal.resetInternal(ExoPlayerImplInternal.java:1411)
at com.google.android.exoplayer2.ExoPlayerImplInternal.stopInternal(ExoPlayerImplInternal.java:1374)
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:591)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:223)
at android.os.HandlerThread.run(HandlerThread.java:67)
E/AudioPlayer: TYPE_RENDERER: Decoder failed: c2.android.flac.decoder

Expected behavior on android device, can normally play some special music

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Flutter SDK version

[✓] Flutter (Channel stable, 3.0.2, on macOS 12.6 21G115 darwin-arm, locale
    zh-Hans-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 14.0)
[✓] Chrome - develop for the web
[!] Android Studio
    ✗ Unable to find bundled Java version.
[✓] Android Studio (version 2021.2)
[✓] IntelliJ IDEA Ultimate Edition (version 2022.2.1)
[✓] VS Code (version 1.68.1)
[✓] Connected device (3 available)
    ! Error: iPhone is not connected. Xcode will continue when iPhone is
      connected and unlocked. (code -13)
[✓] HTTP Host Availability

Additional context Add any other context about the problem here.

ryanheise commented 2 years ago

Can you try updating the ExoPlayer version in just_audio and seeing if it fixes the issue for you?

zhushenwudi commented 2 years ago

I forked the project and upgrade the dependency in Android, But the code made a mistake. The latest Exoplayer seems to be uncompatible with the current code. I may have to change some source code, which may not just improve the version, Can you pull a modified branch for me to test?

zhushenwudi commented 2 years ago

I did it. It can play it correctly!

First, I tried to upgrade the exolayer, but I found that there are still the same error

I got the conclusion by comparing the code with https://github.com/OxygenCobalt/Auxio. There is an additional flac renderer in the exolayer, which uses the official native code of flac and is printed into the so library. exoplayer repo branch is dev. Then I can import the generated aar file extracted from the Auxio project into the dart project

my fork url: https://github.com/zhushenwudi/just_audio

ryanheise commented 2 years ago

Hi @zhushenwudi I have created a branch feature/upgrade_exoplayer where I have upgraded the ExoPlayer version. Can you test it and let me know if there is anything further you need?

ryanheise commented 2 years ago

Hi @zhushenwudi have you had a chance to test this branch yet?

ryanheise commented 2 years ago

I have merged the branch, so I'll close this issue.

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs, or use StackOverflow if you need help with just_audio.