bluefireteam / audioplayers

A Flutter package to play multiple audio files simultaneously (Android/iOS/web/Linux/Windows/macOS)
https://pub.dartlang.org/packages/audioplayers
MIT License
2.01k stars 845 forks source link

[web] Error when pausing and resuming audio from stream URLSource #1264

Closed masus04 closed 1 year ago

masus04 commented 2 years ago

Checklist

An error is thrown when pausing a currently playing audioplayer using a URLSource from a stream. This breaks the audioplayer and makes it impossible to resume playing any source after that.

Current bug behaviour

Starting an audioplayer using a stream URLSource works as intended. When pausing the audioplayer using audioPlayer.pause() and then resuming using audioPlayer.resume(), the following error is thrown and the audioplayer becomes unresponsive to any further commands:

Error: NotSupportedError: Failed to load because no supported source was found.

    at Object.createErrorWithStack (http://localhost:8080/dart_sdk.js:5093:12)
    at Error._throw (http://localhost:8080/dart_sdk.js:20399:18)
    at Error.throwWithStackTrace (http://localhost:8080/dart_sdk.js:20396:18)
    at async._AsyncCallbackEntry.new.callback (http://localhost:8080/dart_sdk.js:40921:18)
    at Object._microtaskLoop (http://localhost:8080/dart_sdk.js:40778:13)
    at _startMicrotaskLoop (http://localhost:8080/dart_sdk.js:40784:13)
    at http://localhost:8080/dart_sdk.js:36261:9

Expected behaviour

The audio should be paused when calling audioPlayer.pause() and resume when calling audioPlayer.resume().

Steps to reproduce

Code sample I'm working on reproducing the error in a minimal example project, however it seems to be somewhat specific to certain technology choices I made, specifically on how the source is provided.

Logs

The error being thrown:

Error: NotSupportedError: Failed to load because no supported source was found.

    at Object.createErrorWithStack (http://localhost:8080/dart_sdk.js:5093:12)
    at Error._throw (http://localhost:8080/dart_sdk.js:20399:18)
    at Error.throwWithStackTrace (http://localhost:8080/dart_sdk.js:20396:18)
    at async._AsyncCallbackEntry.new.callback (http://localhost:8080/dart_sdk.js:40921:18)
    at Object._microtaskLoop (http://localhost:8080/dart_sdk.js:40778:13)
    at _startMicrotaskLoop (http://localhost:8080/dart_sdk.js:40784:13)
    at http://localhost:8080/dart_sdk.js:36261:9
Full Logs Flutter doctor: ``` [✓] Flutter (Channel stable, 3.0.5, on Ubuntu 22.04.1 LTS 5.15.0-46-generic, locale en_US.UTF-8) • Flutter version 3.0.5 at /home/masus/snap/flutter/common/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision f1875d570e (7 weeks ago), 2022-07-13 11:24:16 -0700 • Engine revision e85ea0e79c • Dart version 2.17.6 • DevTools version 2.12.2 [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0) • Android SDK at /home/masus/Android/Sdk • Platform android-33, build-tools 33.0.0 • Java binary at: /snap/android-studio/123/android-studio/jre/bin/java • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840) • All Android licenses accepted. [✓] Chrome - develop for the web • Chrome at google-chrome [✓] Linux toolchain - develop for Linux desktop • clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final) • cmake version 3.10.2 • ninja version 1.8.2 • pkg-config version 0.29.1 [✓] Android Studio (version 2021.2) • Android Studio at /snap/android-studio/123/android-studio • Flutter plugin version 69.0.2 • Dart plugin version 212.5744 • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840) [✓] VS Code • VS Code at /snap/code/current • Flutter extension can be installed from: 🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter [✓] Connected device (2 available) • Linux (desktop) • linux • linux-x64 • Ubuntu 22.04.1 LTS 5.15.0-46-generic • Chrome (web) • chrome • web-javascript • Google Chrome 104.0.5112.101 [✓] HTTP Host Availability • All required HTTP hosts are available • No issues found! ```

Audio Files/URLs/Sources

Environment information

Platform 1:

More information

masus04 commented 2 years ago

Followup issue for https://github.com/bluefireteam/audioplayers/issues/1249

Gustl22 commented 2 years ago

Ok thanks, it would be good to have at least a public API to test the UrlSource against. Otherwise it's almost impossible to help. Good luck.

masus04 commented 2 years ago

I managed to reproduce the error here: https://github.com/masus04/flutter-audiplayers-error

Make sure to run both the frontend & backend. Commands are provided in the readme.

Gustl22 commented 2 years ago

I tried your example and could not reproduce the bug. I used the test.mp3 in the root folder.

Maybe this is solved by #1268

Plz try again with this in your pubspec file:

dependency_overrides:
  audioplayers:
    git:
      url: https://github.com/bluefireteam/audioplayers.git
      path: 'packages/audioplayers'
  audioplayers_platform_interface:
    git:
      url: https://github.com/bluefireteam/audioplayers.git
      path: 'packages/audioplayers_platform_interface'
  audioplayers_web:
    git:
      url: https://github.com/bluefireteam/audioplayers.git
      path: 'packages/audioplayers_web'
  audioplayers_linux:
    git:
      url: https://github.com/bluefireteam/audioplayers.git
      path: 'packages/audioplayers_linux'
  audioplayers_android:
    git:
      url: https://github.com/bluefireteam/audioplayers.git
      path: 'packages/audioplayers_android'
Gustl22 commented 2 years ago

You can now also use the newest release: audioplayers: ^1.1.0

Gustl22 commented 1 year ago

@masus04 can you reconfirm with newer versions of AP?

masus04 commented 1 year ago

Can confirm that the issue no longer persists with the latest versions.