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)`
Someone already is asking that Flutter Sound does not wait all the song to be downloaded, and starts the playback during the download. (I am not able to tell you which issue number, but perhaps you can find this issue). I am sure that it is something that we must improve : some users wants to playback very large files and the download is sometimes very slow.
This issue is very high in the TODO stack. I would be very glad if someone does something for that soon.
yes . its the issue , please provide the solution , UI freezes in Android , when start player
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)`
have you get any solution ? , i also need solution for this
Someone already is asking that Flutter Sound does not wait all the song to be downloaded, and starts the playback during the download. (I am not able to tell you which issue number, but perhaps you can find this issue). I am sure that it is something that we must improve : some users wants to playback very large files and the download is sometimes very slow.
This issue is very high in the TODO stack. I would be very glad if someone does something for that soon.
please provide the solution for app UI freeze in android , when startPlayer called
@Alvarocda, this is another issue waiting for more than one year. You can also look to #771. There are other issues about this subject, but I am not able to find them in all this mess in the Problem Reports.
The code that download the remote file on Android was coded by @salvatore373 or @hyochan (I do not know very well). So I will not be able to help you very much if you are interested by this issue. I will just introduce you the the good Android source entry point.
Okay, I'll take a look at this one too
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
Hey, i think i found the problem that is causing this. It is on the Android Side i am changing the code but when i debug it the code doesn't change, it is using github source and not my local version of the Android Side.
How can i build the app using my version of the Android Side? I think this file do this -> tau10\tau_sound\android\build.gradle (Line 57) but i cant get this to work
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\dev\tau10\tau_sound\android\build.gradle' line: 57
* What went wrong:
A problem occurred evaluating project ':tau_sound'.
> Project with path ':tau_native' could not be found in project ':tau_sound'.
Hi my friend,
I told you that I will explain how to develop/debug the Android or iOS code.
There is a very basic documentation here, but is not uptodate. For example what is called tau_core in the documentation is now called tau_native in Tau Sound 9.0.
1. restore all your config files
For example your build.gradle scripts. It is important that all the config files are exactly as it was in the git repository, because my scripts does many sed commands and expect to have unmodified scripts.
2. Fork the github project tau_native
This project contains all the iOS and Android code.
If you look to this diagram, tau_native is documented as tau_core in the bottom of the diagram
3. Add this fork as a submodule of your tau10 fork
I am not a git expert, but you will find on Google how to create a submodule in a git project.
What is important for me, is that you will have a directory tau10/tau_native with all the native code.
4. bin/reldev DEV
cd tau10
bin/reldev.sh DEV
This script is to set a development environment. This is this script which for example change your build.gradle files. As I wrote a few lines above, it is important that all your config files are not modified directely by you
5. bin/flavor.sh LITE
This script is to set a LITE flavor of your configuration files. I suggest that you use the LITE flavor and not the FULL flavor, because you are currently not working on FFmpeg
cd tau10
bin/flavor.sh LITE
6. Flutter pub get
Under tau10/tau_sound/example.
cd tau10/tau_sound/example
flutter pub get
flutter clean
7. Cocoapod
Cocoapod is a little painful tool. It is possible that you must reset your Podifles :
cd tau10/tau_sound/example/ios
rm Podfile.lock
pod install --repo-update
If you plan to work on this issue :
- First you want to understand the Issue as entered by Tau Sound users :
- Is really the App frozen during the download ? (no UI during the download). If this is the bug, then it means that the download is done on the main thread without running the Flutter main loop
- Or is the problem that the playback does not begin until all the sound is downloaded ?
-
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
-
I think that it will not be easy to try to playback during the download. If the download is slow (slow internet), then it will be possible that the playback is faster than the download. It will stop the playback before the end of the sound. It can be interesting to see how the other tools manage that (AudioPlayers, or JustAudio for example).
-
We had an issue a very long time ago, asking that the downloaded file will be cached in memory, in case the App wants to playback the file several times. I am not sure that this request must be answered, but I mention it.
-
It is interesting to understand why iOS is OK but Android is not OK. I think that the big difference is that on iOS, Tau Sound does not download the file. It just request the playback to the OS AVAudioPlayer, and everything is done by the OS. On Android, I think that we download the file ourself. Of course we must check that Android is not able to do do same with its "Audio Media Player". If Android can do that it will be fantastic.
The Android Sources :
The main source of the player is tau10/tau_native/android/src/main/java/xyz/canardoux/TauNative/FlautoPlayer.java.
Line 203, we instanciate the FlautoEngine:
player = new FlautoPlayerMedia(this);
The low level class for our Media Player is : tau10/tau_native/android/src/main/java/xyz/canardoux/TauNative/FlautoPlayerMedia.java. Line 49, we ask Android to prepare the playback :
mediaPlayer.setOnPreparedListener(mp -> {flautoPlayer.play(); flautoPlayer.onPrepared();});
Line 310 of tau10/tau_native/android/src/main/java/xyz/canardoux/TauNative/FlautoPlayer.java
we give the final completion indication to the dart side. (see the doc that I am preparing for you)
NOTE:
When I read the code, it seems that we do not download ourself the file, but just ask Android to play the remote URL. If I am right, this is a very good news:
As I told you in another post, your task is
- Check that Android do not freeze the UI during the
prepare()line 52 of FlautoPlayerMedia.java
I think that it is not possible to execute flautoPlayer.play(); (in the callback line 49) before. For example juste after the
mediaPlayer.prepare(); line 52. Android will not be Happy because you may not run play before the end of prepare.
}
- 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.
I'm not able to run the reldev.sh and flavor.sh scripts because they need some component called gsed and I don't have it installed on my Windows.
When I run the scripts, it just shows me several "gsed: command not found"
I will try to install Linux on another partition and try again.
If you run macos, just do :
brew install gsed
(of course you need to install brew. But a Mac developer cannot live without brew)
On windows I do not know. Probably good to install "ubuntu" under windows. https://ubuntu.com/tutorials/ubuntu-on-windows#1-overview
When I run Windows, I always install linux on it, to have a descent shell (and not cmd.com and other disgusting Windows tools)
WSL is very convenient
Cygwin is also a very good product, to have a descent shell. But if you install Ubuntu under WSL you probably do not need cygwin
So, i tryed Cygwin and a sed package from chocolatey and this happens when i try to run

And in WSL, i have this

This is my tau10 folder

This is because Windows user cr-lf (two chars) to separate lines, but Linux use just lf (or new-line if you prefer)
Just a moment, I will tell you how to remove the CR with vi. Do you know vi ?
https://www.cyberciti.biz/faq/how-to-remove-carriage-return-in-linux-or-unix/
Ok, i removed all CRs from the file and then i tried to run
it gives me the same erros as in windows, gsed is not found

i renamed gsed to only sed in reldev.sh and now it gives me the same error message as windows

try :
sudo apt-get install gsed
Sous ubuntu
try :
sudo apt-get install gsedSous ubuntu
It was the first thing i tryed 😢
Unable to locate package gsed
I am running ubuntu here
minute. I am looking ....
https://unix.stackexchange.com/questions/75749/how-to-share-a-gnu-sed-script-between-linux-and-mac-os-x
Probably the simpler is to do an alias
alias gsed 'sed -f'
And then try to type just "gsed" to verify that the command gsed is now OK
No, I am probably wrong. On linux, sed is the GNU sed (gsed).
I thing that just an alias is OK :
alias gsed 'sed'
Do not bother with the errors on Podfile. Podfile is for iOS. On Windows and Linux, you cannot develop for iOS
Just ignore the errors on Podfile
The problems that you had after renaming "gsed" as "sed" is because you did not run your script under tau10 but under tau10/bin