florent37 / Flutter-AssetsAudioPlayer

Play simultaneously music/audio from assets/network/file directly from Flutter, compatible with android / ios / web / macos, displays notifications
https://pub.dartlang.org/packages/assets_audio_player
Apache License 2.0
757 stars 368 forks source link

Error when using Audio.file #348

Closed mehmetext closed 4 years ago

mehmetext commented 4 years ago

Flutter Version

My version : 1.20.3

Platform (Android / iOS / web) + version

Platform : Android 9.0

Describe the bug

when I want to play an audio from local(Audio.file), I can play it but it gives an error like this: https://prnt.sc/ue5a5x. Then If I play again it, it doesn't give any error and it doesn't play.

Small code to reproduce


E/ExoPlayerImplInternal(15668): Source error
E/ExoPlayerImplInternal(15668):   com.google.android.exoplayer2.ParserException: Expected block size: 2; got: 1
E/ExoPlayerImplInternal(15668):       at com.google.android.exoplayer2.extractor.wav.WavExtractor$PassthroughOutputWriter.<init>(WavExtractor.java:222)
E/ExoPlayerImplInternal(15668):       at com.google.android.exoplayer2.extractor.wav.WavExtractor.read(WavExtractor.java:122)
E/ExoPlayerImplInternal(15668):       at com.google.android.exoplayer2.source.ProgressiveMediaPeriod$ExtractingLoadable.load(ProgressiveMediaPeriod.java:982)
E/ExoPlayerImplInternal(15668):       at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:391)
E/ExoPlayerImplInternal(15668):       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/ExoPlayerImplInternal(15668):       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/ExoPlayerImplInternal(15668):       at java.lang.Thread.run(Thread.java:764)
I/ExoPlayerImpl(15668): Release 66d77bc [ExoPlayerLib/2.11.4] [generic_x86_64, Android SDK built for x86_64, Google, 28] [goog.exo.core]
V/MediaPlayer(15668): resetDrmState:  mDrmInfo=null mDrmProvisioningThread=null mPrepareDrmInProgress=false mActiveDrmScheme=false
V/MediaPlayer(15668): cleanDrmObj: mDrmObj=null mDrmSessionId=null```
johnny-stevie commented 4 years ago

It may be that the file is corrupt, the wav type issue if the player isn't comfortable at parsing it. Try playing a different wav file and see if the problem persists.

mehmetext commented 4 years ago

It may be that the file is corrupt, the wav type issue if the player isn't comfortable at parsing it. Try playing a different wav file and see if the problem persists.

Actually I use flutter_audio_recorder to record audio. I want to play what I record with assets_audio_play. @johnny-stevie

kalismeras61 commented 4 years ago

It may be that the file is corrupt, the wav type issue if the player isn't comfortable at parsing it. Try playing a different wav file and see if the problem persists.

Actually I use flutter_audio_recorder to record audio. I want to play what I record with assets_audio_play. @johnny-stevie

@mehmetext change audio recording format with .m4a and try again. Because as i understand it is playback app no need to store with wav extension.

johnny-stevie commented 4 years ago

Try creating another recording with another file format like mp4, or just playing a different wav file thats off the web. If neither work, then I would do a flutter clean build and recompile.

mehmetext commented 4 years ago

I tried another audio (format: .aac) from file. It plays but it doesn't give the audio duration 🤔 Also I did flutter clean so much :D

mehmetext commented 4 years ago

It may be that the file is corrupt, the wav type issue if the player isn't comfortable at parsing it. Try playing a different wav file and see if the problem persists.

Actually I use flutter_audio_recorder to record audio. I want to play what I record with assets_audio_play. @johnny-stevie

@mehmetext change audio recording format with .m4a and try again. Because as i understand it is playback app no need to store with wav extension.

@kalismeras61 I tried it but nothing changed. It gives same error.

kalismeras61 commented 4 years ago

@mehmetext it looks like recorder plugin problem.

Check this : https://github.com/rmbrone/flutter_audio_recorder/issues/11

Solution : https://github.com/rmbrone/flutter_audio_recorder/issues/11#issuecomment-654289094

johnny-stevie commented 4 years ago

It would be best if you did 2 thorough tests:

  1. Test every recording file format and see if you get the error.
  2. Try playing external files of the same formats(not recordings but something off the web) And posted your error logs instead of just describing them. Also, about the audio duration, did you do _assetsAudioPlayer.duration.listen((){}) ? I'm not sure about the exact stream name, but you have to subscribe to it to get the latest audio duration.
mehmetext commented 4 years ago

@mehmetext it looks like recorder plugin problem.

Check this : rmbrone/flutter_audio_recorder#11

Solution : rmbrone/flutter_audio_recorder#11 (comment)

@kalismeras61 I tried this solution but it couldn't solve my problem. Also, I think there is no problem about recorder plugin. Because I can play it one time but I can not play it or something else more. And I used audio_recorder plugin instead of flutter_audio_recorder plugin. The problem is same again 🤔

It would be best if you did 2 thorough tests:

  1. Test every recording file format and see if you get the error.
  2. Try playing external files of the same formats(not recordings but something off the web) And posted your error logs instead of just describing them. Also, about the audio duration, did you do _assetsAudioPlayer.duration.listen((){}) ? I'm not sure about the exact stream name, but you have to subscribe to it to get the latest audio duration.

@johnny-stevie I use PlayerBuilder.realtimePlayingInfos, so I can get audio duration. Audio from network gives but Audio from file doesn't give me the duration. Actually there is no error logs in terminal 🤔

johnny-stevie commented 4 years ago

Did you try using the record_mp3 package like in the issue referenced by @kalismeras61 ?

mehmetext commented 4 years ago

Did you try using the record_mp3 package like in the issue referenced by @kalismeras61 ?

@kalismeras61, @johnny-stevie thank you so much. I used record_mp3 plugin and there is no problem for now.

kalismeras61 commented 4 years ago

@mehmetext ok cool. If it is fixed. Please close this issue.