Open tanvi-iosdev opened 3 years ago
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.
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.
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
tau10
forkI 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.
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
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
Under tau10/tau_sound/example.
cd tau10/tau_sound/example
flutter pub get
flutter clean
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 :
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)
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
prepare()
line 52 of FlautoPlayerMedia.javaI 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 ?
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 gsed
Sous ubuntu
It was the first thing i tryed 😢
Unable to locate package gsed
I am running ubuntu here
minute. I am looking ....
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
you must do :
cd tau10
bin/reldev.sh DEV
My scripts are not very sophisticated. Until today, I was the only person to use it. You are the second 🥇
I do not know exactly who added the CR after all the LF :
git
added them because you was running git under Windows.I suggest that you use the git
command under Linux and not under Windows.
Okay, I deleted the clone I had and cloned the entire repository again.
I managed to run both scripts without errors (bin/reldev.sh DEV and bin/flavor.sh LITE)
However, I still can't run the app.
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'.
are you sure that you have checkout all the sources under tau10/tau_native ?
You must have a subproject tau_native
correctly setup inside your directory tau10
OK. This is my fault. I have something wrong in my scripts. Minute ...
in tau10/tau_sound/android/settings.gradle I wrote something wrong line 7
It should be :
project(':tau_native').projectDir = file('../../tau_native/android')
I am sorry
are you sure that you have checkout all the sources under tau10/tau_native ?
You must have a subproject
tau_native
correctly setup inside your directory tau10
i cloned the tau10 repository using
git clone --recursive
the content of tau_native folder inside my tau10 folder
when open tau_native with my git bash, it shows me the branch i am using (or tag)
in tau10/tau_sound/android/settings.gradle I wrote something wrong line 7
It should be :
project(':tau_native').projectDir = file('../../tau_native/android')
I am sorry
in tau10/tau_sound/android/settings.gradle I wrote something wrong line 7
It should be :
project(':tau_native').projectDir = file('../../tau_native/android')
I am sorry
i updated the file, but the error continues 😭
You can check tau10/tau_sound/example/android/settings.gradle
but I do not see why it would be wrong ...
OH : do your run the example or something else ?
OH : do your run the example or something else ?
nope. only flutter pub get and flutter clean inside example folder
OK. I am studying that. A moment please ...
I do not see. The android libraries directories are declared inside the two settings.graddle :
Graddle should be able to find the tau_native
library
- What went wrong: A problem occurred evaluating project ':tau_sound'.
Project with path ':tau_native' could not be found in project ':tau_sound'.
This is weird
Double check tau_sound/android/settings.graddle
If necessary, put a HARD path to tau_native/android (just to see if better)
tau_sound/android/settings.graddle
//ext.flutterFFmpegPackage = 'audio'
group 'xyz.canardoux.tausound'
version '0.0.1-alpha-10+1'
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.1'
}
}
rootProject.allprojects {
repositories {
maven( { url 'https://jitpack.io' })
google()
mavenCentral()
}
}
apply plugin: 'com.android.library'
android {
compileSdkVersion 30
defaultConfig {
minSdkVersion 18 // 18 works fine for the player, but the recorder needs at least 24
}
lintOptions {
disable 'InvalidPackage'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
String safeExtGet(String prop, String fallback) {
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}
dependencies {
//---implementation 'com.arthenica:mobile-ffmpeg-full:4.4.LTS'
implementation 'androidx.core:core:1.3.2'
implementation 'androidx.media:media:1.2.0'
implementation 'androidx.appcompat:appcompat:1.2.0'
// -------------------------------------------------------------------------------------
// CAUTION: The following instruction is for developping and debugging the Flauto Engine
// DO NOT INCLUDE THE FOLLOWING LINE IN A REAL APP !!!
implementation project(':tau_native')
//implementation 'com.github.canardoux:tau_native:0.0.1-alpha-4'
// -------------------------------------------------------------------------------------
}
tau_sound/example/android/settings.graddle
ext.flutterFFmpegPackage = 'audio'
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
if you want to, i can give you access to my PC via Teamviewer or Anydesk so you can see what might be causing this
My settings are much simple :
rootProject.name = 'tau_sound_lite'
// -------------------------------------------------------------------------------------
// CAUTION: The following instruction is for developping and debugging the Flauto Engine
// DO NOT INCLUDE THE FOLLOWING LINES IN A REAL APP !!!
project(':tau_native').projectDir = file('../../tau_native/android')
// -------------------------------------------------------------------------------------
and
include ':app'
def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
def plugins = new Properties()
def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
if (pluginsFile.exists()) {
pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
}
plugins.each { name, path ->
def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
include ":$name"
project(":$name").projectDir = pluginDirectory
}
// -------------------------------------------------------------------------------------
// CAUTION: The following instruction is for developping and debugging the Flauto Engine
// DO NOT INCLUDE THE FOLLOWING LINES IN A REAL APP !!!
include 'tau_native'
project(':tau_native').projectDir = file('../../../tau_native/android')
// -------------------------------------------------------------------------------------
oops, i copied build.gradle and not settings.gradle, my mistake
Is it ΟΚ now ?
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)`