Open sebastianconcept opened 9 years ago
which platform?
Both, in my app Android (5.0.2) and iOS (8.3) @kaansoral
@kaansoral I was taking a look here: https://developer.apple.com/library/ios/documentation/AVFoundation/Reference/AVAudioPlayerClassReference/index.html#//apple_ref/occ/instp/AVAudioPlayer/numberOfLoops
and we seem to be doing the right thing.
I'm feeling lost now =/
I've been inspecting the ios/android versions deeply, both ios and android have complicated sound routines on their own, at least ios can perform decent sound performance
I just tested the .loop on iOS for you, indeed .loop doesn't work, the audio just plays simultaneously multiple times ...
I'm sure you can manually fix it on iOS, yet android devices might not even be capable of reliably looping a simple sound ...
I would try setting the number of loops to 1000 as a starter
Worth trying!
Regarding to Android, here people mentions that MediaPlayer might not be gapless at looping =( http://stackoverflow.com/questions/11951420/how-do-i-loop-my-media-player-files
and that SoundPool is better: http://developer.android.com/reference/android/media/SoundPool.html
Thanks for the info, I will check SoundPool out, I'm using this plugin mainly for UI sounds, android can't even play small sound effects properly, so I was going to write a plugin to do these: http://stackoverflow.com/questions/7914518/how-to-play-default-tick-sound
I will check SoundPool before that
The UI sounds are pretty similar to looped sounds, they need to be able to play one after another fast, so we're roughly trying to do similar things
I think you should find an iOS solution, yet for Android it's extremely challenging, at times like these I find a substitute solution for Android and move on, hoping things work out at least on some devices, android4 wasn't this bad for example, after I upgraded to android5 things got pretty worse
This is also an interesting analysis: http://superpowered.com/latency/#table
I'm confused now. I've tested the drumpad
example isolated and it works in android and iOS, including loop
So I now suspect of issues in how I'm trying to use it from the concrete app where I need this (Meteor based)
Did you check the sounds of the drumpad example on your project, I have a hunch the bitrate of sounds might be affecting things
@kaansoral in fact I've discovered that the mp3 of my projects have a gap so the loop has a gap, but they are indeed looping.
So at this point I'm unstuck on iOS which is great.
On Android, the story is different. It works looping fine on the first touchstart
but the loop
performs like a play
after the asset received a .stop()
I'm investigating this.
The main reason why all this didn't work from the first try was that I was sending the wrong path to prepareComplex
because I was sending the absolute path and the play
and loop
functions are doing some path concatenation with www
right there and failing completely silently. Some NSLog helped me to dig and discover what was going on.
For the record, this might be what we need for android: http://stackoverflow.com/questions/9461270/media-player-looping-android "once you call stop(), you have to call prepare()/prepareAsync() before calling start() again"
Maybe this is considering the play but not the loop case: https://github.com/floatinghotpot/cordova-plugin-nativeaudio/blob/master/src/android/NativeAudioAssetComplex.java#L60
In my case, there is something very wrong with android//my-specific-device, even the basic sound effects aren't playing properly
I ended using: https://github.com/VVelda/device-feedback - as I was using sound effects for feedback - I don't think I will lose any more time with the absurdities of android
I also think a basic configuration issue or usage issue might be causing these problems, but I don't have any energy left to test various stuff
As a suggestion to you, it might be worthwhile to read the MediaPlayer documentation and test each flag/setting one by one until you achieve what you want
By the way, can you reliably play sounds one after another?
@kaansoral I can play in Android but I've only tested in one device with 5.0.2. Later I'll test in some 4.x
What about the drumpad demo app? also not working for you?
And thanks for the tip, indeed the machine state is important to get right, and is what I'm suspecting about this plugin (not having some case managed properly) http://developer.android.com/reference/android/media/MediaPlayer.html
I did now, it works well with the same plugins I use in my main app The sound performance isn't high, but at least the highhat is relatively satisfying
I think, no matter what the technical situation is and no matter what people say, 48.000Hz mp3's might be the optimal format for androids
I have 16-bit 44.100/48.000Hz wavs that perform really bad, going to try 48.000Hz mp3's next
I've experimented a bit last night and I can confirm that there is definitively a problem in the machine state of NativeAudioAssetComplex.java
for loop
If I can get a gapless loop with a couple of mp3 I need, I might work in getting it fixed, but for sure that machine state is buggy
Hi there! I can't get
.loop
to work actually looping. It's behaving exactly as.play
. I'm usingpreloadComplex
and play works well but can't make it loop.Any pointers?
This plugin is awesome!