Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception on playing my audio #158

Closed
hesham91fci opened this issue Aug 24, 2020 · 13 comments
Closed

Exception on playing my audio #158

hesham91fci opened this issue Aug 24, 2020 · 13 comments
Assignees
Labels
1 backlog bug Something isn't working

Comments

@hesham91fci
Copy link

Which API doesn't behave as documented, and how does it misbehave?
setAsset, setURL, setFilePath all of them throws the same exception when playing some audio file recorded using flutterRecorder,

  • Extension is .wav
  • sampling rate is 16000
  • file is playing normally using other players in my phone
  • file is playing normally using AudioPlayers plugin
    Minimal reproduction project
    https://github.com/hesham91fci/just_audio

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

  1. Embed the located (.wav) file as an asset in your pubspec.yaml
  2. try to play it using setAsset method
  3. use method play() to play the file
  4. see the following error message in error message section

Error messages

E/ExoPlayerImplInternal(12865): Source error
E/ExoPlayerImplInternal(12865):   com.google.android.exoplayer2.ParserException: Expected block size: 2; got: 1
E/ExoPlayerImplInternal(12865):       at com.google.android.exoplayer2.extractor.wav.WavExtractor$PassthroughOutputWriter.<init>(WavExtractor.java:222)
E/ExoPlayerImplInternal(12865):       at com.google.android.exoplayer2.extractor.wav.WavExtractor.read(WavExtractor.java:122)
E/ExoPlayerImplInternal(12865):       at com.google.android.exoplayer2.source.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:982)
E/ExoPlayerImplInternal(12865):       at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:391)
E/ExoPlayerImplInternal(12865):       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
E/ExoPlayerImplInternal(12865):       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
E/ExoPlayerImplInternal(12865):       at java.lang.Thread.run(Thread.java:764)
E/AudioPlayer(12865): TYPE_SOURCE: Expected block size: 2; got: 1
E/flutter (12865): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: (0) com.google.android.exoplayer2.ParserException: Expected block size: 2; got: 1
E/flutter (12865): #0      AudioPlayer._load (package:just_audio/just_audio.dart:461:9)
E/flutter (12865): <asynchronous suspension>
E/flutter (12865): #1      AudioPlayer.load (package:just_audio/just_audio.dart:425:30)
E/flutter (12865): #2      AudioPlayer.setAsset (package:just_audio/just_audio.dart:411:7)
E/flutter (12865): #3      _MyHomePageState._listenToAudio (package:just_audio_example/main.dart:52:23)
E/flutter (12865): #4      _AsyncAwaitCompleter.start (dart:async-patch/async_patch.dart:45:6)
E/flutter (12865): #5      _MyHomePageState._listenToAudio (package:just_audio_example/main.dart:50:30)
E/flutter (12865): #6      _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:706:14)
E/flutter (12865): #7      _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:789:36)
E/flutter (12865): #8      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
E/flutter (12865): #9      TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:486:11)
E/flutter (12865): #10     BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:264:5)
E/flutter (12865): #11     BaseTapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:199:7)
E/flutter (12865): #12     PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:467:9)
E/flutter (12865): #13     PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:76:12)
E/flutter (12865): #14     PointerRouter._dispatchEventToRoutes.<anonymous closure> (package:flutter/src/gestures/pointer_router.dart:117:9)
E/flutter (12865): #15     _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:379:8)
E/flutter (12865): #16     PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:115:18)
E/flutter (12865): #17     PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:101:7)
E/flutter (12865): #18     GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:218:19)
E/flutter (12865): #19     GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:198:22)
E/flutter (12865): #20     GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156:7)
E/flutter (12865): #21     GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7)
E/flutter (12865): #22     GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7)
E/flutter (12865): #23     _rootRunUnary (dart:async/zone.dart:1138:13)
E/flutter (12865): #24     _CustomZone.runUnary (dart:async/zone.dart:1031:19)
E/flutter (12865): #25     _CustomZone.runUnaryGuarded (dart:async/zone.dart:933:7)
E/flutter (12865): #26     _invoke1 (dart:ui/hooks.dart:273:10)
E/flutter (12865): #27     _dispatchPointerDataPacket (dart:ui/hooks.dart:182:5)

Expected behavior
Audio file should plays normally.

Screenshots
N/A

Desktop (please complete the following information):

  • OS: MacOS catalina
  • Browser [Chrome]

Smartphone (please complete the following information):

  • Device: [Sony xperia XA1 ultra]
  • OS: [Android 8.0]

Flutter SDK version

[✓] Flutter (Channel stable, v1.12.13+hotfix.9, on Mac OS X 10.15.4 19E287,
    locale en-EG)
 
[!] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    ! Some Android licenses not accepted.  To resolve this, run: flutter doctor
      --android-licenses
[✓] Xcode - develop for iOS and macOS (Xcode 11.4.1)
[✓] Android Studio (version 3.5)
[✓] Connected device (1 available)

Additional context
I've modified the original pubspec file as I'm using flutter 1.12.13.

@hesham91fci hesham91fci added 1 backlog bug Something isn't working labels Aug 24, 2020
@ryanheise
Copy link
Owner

Hi @hesham91fci , unfortunately parsing errors are outside of my control since the issue is with ExoPlayer itself (Google's media player library). You can post a bug report on Google's issues page and provide a link to the wav file that is triggering the issue:

https://github.com/google/ExoPlayer/issues

@hesham91fci
Copy link
Author

@ryanheise Thanks a lot for your immediate reply, but can you please demonstrate why AudioPlayer plugin plays this file normally ?

@ryanheise
Copy link
Owner

Do you mean the audioplayer plugin? That is because it is using an older Android API that doesn't have this bug. The latest APIs, however, have this bug.

@hesham91fci
Copy link
Author

hesham91fci commented Aug 24, 2020

@ryanheise , yes I mean AudioPlayer plugin, Does it means that falling back to versions earlier than 0.3.4 could be the fix ?

@ryanheise
Copy link
Owner

You'd have to go back to 0.0.1. Not really a good option since the latest APIs are the most powerful.

One thing you can try as a workaround is use a different audio recorder plugin. I haven't checked them all, but if you can find one that records and encodes in a different format, you might be able to dodge the parsing error when it comes time to play it.

Looking at what's available, a number of them support recording to AAC which will probably work better for you as in addition to possibly fixing your parsing error, it will also compress the audio.

@hesham91fci
Copy link
Author

Also another technical question, isn't just_audio plugin wraps inside it AudioPlayer plugin ?

@ryanheise
Copy link
Owner

just_audio was written independently from the ground up using the latest APIs. As such, it has no relation to any other audio plugin on pub.dev.

@dfdgsdfg
Copy link

dfdgsdfg commented Aug 31, 2020

Same here. This report is just for record case.

I generated the Wave file from https://github.com/rmbrone/flutter_audio_recorder/.

In my case, the android mediaplayer seems to work well for the first time. Strange.

Anyway, thanks for your all great work! 👍 👍 👍 👍

@ryanheise
Copy link
Owner

@dfdgsdfg what if you encode to a different audio format?

@dfdgsdfg
Copy link

@ryanheise In my case, the recorder generated a bad header.

rmbrone/flutter_audio_recorder#11

I think, there is no problem with exoplayer or just_audio.

Thanks.

@ryanheise
Copy link
Owner

@dfdgsdfg I agree, thanks for investigating it. I'll close this issue, and recommend those who run into this issue to wait for a fix in the recorder plugin or switch to another recorder plugin that outputs the correct header.

@hesham91fci
Copy link
Author

@ryanheise I switched the recorder plugin from flutter_audio_recorder to audio_recorder and it worked fine

@github-actions
Copy link

github-actions bot commented Nov 6, 2021

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
1 backlog bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants