bluefireteam/audioplayers

`onPlayerComplete` does not fire on Android when the player mode is low latency

songyang-dev opened this issue · 2 comments

Checklist

  • I read the troubleshooting guide before raising this issue
  • I made sure that the issue I am raising doesn't already exist

Current bug behaviour

The player does not fire a completion event when the playback ends if the player is set in low latency mode. This can only happen on Android.

Expected behaviour

An event is fired in the onPlayerComplete stream when the player finishes the audio.

Steps to reproduce

  1. Execute flutter run on the code sample
  2. Click the "Play" button to hear a piano note.
  3. If the completion event works, you should hear a second piano note.

Code sample

https://github.com/songyang-dev/audioplayers_completion_bug

Affected platforms

Android

Platform details

Android emulator. Pixel 8 with API 34.

AudioPlayers Version

6.0.0

Build mode

debug

Audio Files/URLs/Sources

The audio files are available in the assets/ folder of the linked repo.

Screenshots

No response

Logs

Full Logs

Flutter doctor:

[√] Flutter (Channel stable, 3.19.6, on Microsoft Windows [Version 10.0.22631.3447], locale en-CA)
  • Flutter version 3.19.6 on channel stable at C:\dev\flutter
  • Upstream repository https://github.com/flutter/flutter.git
  • Framework revision 54e66469a9 (2 weeks ago), 2024-04-17 13:08:03 -0700
  • Engine revision c4cd48e186
  • Dart version 3.3.4
  • DevTools version 2.31.1

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
  • Android SDK at C:\Users\songy\AppData\Local\Android\sdk
  • Platform android-34, build-tools 34.0.0
  • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
  • Java version OpenJDK Runtime Environment (build 17.0.9+0--11185874)
  • All Android licenses accepted.

[√] Chrome - develop for the web
  • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.9.4)
  • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
  • Visual Studio Community 2022 version 17.9.34714.143
  • Windows 10 SDK version 10.0.22621.0

[√] Android Studio (version 2023.2)
  • Android Studio at C:\Program Files\Android\Android Studio
  • Flutter plugin can be installed from:
     https://plugins.jetbrains.com/plugin/9212-flutter
  • Dart plugin can be installed from:
     https://plugins.jetbrains.com/plugin/6351-dart
  • Java version OpenJDK Runtime Environment (build 17.0.9+0--11185874)

[√] VS Code (version 1.89.0)
  • VS Code at C:\Users\songy\AppData\Local\Programs\Microsoft VS Code
  • Flutter extension version 3.88.0

[√] Connected device (4 available)
  • sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64    • Android 14 (API 34) (emulator)
  • Windows (desktop)            • windows       • windows-x64    • Microsoft Windows [Version
    10.0.22631.3447]
  • Chrome (web)                 • chrome        • web-javascript • Google Chrome 122.0.6261.129
  • Edge (web)                   • edge          • web-javascript • Microsoft Edge 124.0.2478.67

[√] Network resources
  • All expected network resources are available.

• No issues found!

Related issues / more information

Related: #1675

Working on PR

yeah

Unfortunately this is by design due to limitations of Android Pool Player:
https://github.com/bluefireteam/audioplayers/blob/main/getting_started.md#player-mode
You should stop the player by yourself if you know the length of your audio sample or just reuse the player for playing the same audio multiple times.

Oh, thanks for telling me!