flutter_sound: Issue : Start Player Freezes the app

Flutter Sound Version : 7.8.4

When play button click flutter app freezes until audio starts playing. This is happening in only Android app, iOS app doesn’t freeze Can anyone provide the solution?

Start Player Code

Future<void> startPlayer(String url) async { try { if (url != null) { await _ChatState.playerModule.startPlayer( fromURI: url, codec: Codec.aacMP4, whenFinished: () { stopPlayer(); }); } } catch (err) { print('error: $err'); } }

Flutter Doctor

`[✓] Flutter (Channel unknown, 1.22.6, on Mac OS X 10.15.5 19F101 darwin-x64, locale en-GB) • Flutter version 1.22.6 at /Volumes/Workspace/Software/flutter • Framework revision 9b2d32b605 (8 months ago), 2021-01-22 14:36:39 -0800 • Engine revision 2f0af37152 • Dart version 2.10.5

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2) • Android SDK at /Users/pavans/Library/Android/sdk • Platform android-30, build-tools 30.0.2 • ANDROID_HOME = /Users/pavans/Library/Android/sdk • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495) • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.1) • Xcode at /Volumes/Workspace/Software/iOS/xCode/12.1/Xcode.app/Contents/Developer • Xcode 12.1, Build version 12A7403 • CocoaPods version 1.10.1

[✓] Android Studio (version 4.1) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin installed • Dart plugin version 201.9306 • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)

[✓] VS Code (version 1.60.0) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.25.0

[✓] Connected device (2 available)`

About this issue

Most upvoted comments

Good news 🎉 I’ve managed to solve this problem 😄 Now, the app will not freeze with slow connections or no connection at all.

Now the bad news 😭 If the user does not have an internet connection, the lib will try to download the audio for approximately 40 seconds, the app will not freeze while this time passes, after these 40 seconds the app will go into a stopped state because it could not download. When it enters this state, the user cannot start the player again.

As far as I could figure out, the Lock on line 335 of the tau_sound/lib/public/tau_player.dart file is causing this issue of not letting the player start again.

If the user closes the player and opens it again, he is able to try to start the player again.

Well, anyway, I’m trying to solve this problem too.

Is there any update on the issue? This issue is still occurring on flutter_sound: ^9.2.13.

OK. You are probably right. I am going to look that.

But just wait a little bit, I am actually busy releasing Flutter_Sound 8.4 and Tau_sound 9.0 (with your PullRequest included 😄 )

I am going to look to that. Probably in one hour. Patience …

Note : I am renaming the name of the project (tau10) as a simply tau. tau10 was temporary. I hope that that you are not having problems with this rename

Good morning @Alvarocda ,

I cloned the repository with the fixes you made today, but it seems like the problem with the module R continues

I am very sorry. I pushed on github the tau10 project instead of tau_native. 👎 It should be better now.

BTW: I suggest that we use another tool to work together, because we are actually polluating #762.

  • Something like slack (which is Close source 👎 ),
  • Zoom (which is also Close Source 👎 )
  • Or another tool if you know something convenient for us

BTW : I am realizing that actually Java does not compile because I have undefined symbols Under the module R.

I do not understand why. I am going to fix that, so do not loose time on errors like

error: cannot find symbol
                                .setColor(ContextCompat.getColor(context, R.color.colorPrimaryDark))
                                                                                 ^
  symbol:   variable colorPrimaryDark
  location: class color

The problem is on my side

you must do :

cd tau10
bin/reldev.sh DEV

Do not bother with the errors on Podfile. Podfile is for iOS. On Windows and Linux, you cannot develop for iOS

  • You need to understand the processing flow that Tau Sound execute. I am going to write a documentation of this flow, today, and I will post you the URL

here it is. Please, tell me if it makes sense for you.

Someone posted something to say that this point was correctly solved by another Flutter plugin. I do not remember which one. Perhaps JustAudio or AudioPlayers.

We probably can borrow their code instead of rewriting everything