Issue : Start Player Freezes the app
See original GitHub issueFlutter 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)`
Issue Analytics
- State:
- Created 2 years ago
- Comments:82
Top GitHub 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.
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 😄 )