Libgdx audio wav file not playing soundpool not ready? - android

I am trying to add sound to my Libgdx game using a wav file. It is supposed to play in the background of the main menu and loop but for some reason it does not play. Does anyone have any insight into way this may be. I also notice in the logcat that soundpool is not ready. I have added the following code to the constructor of my screen and the file is located in my assets folder. Thanks.
Sound wavSound = Gdx.audio.newSound(Gdx.files.internal("sound.wav"));
wavSound.play();

Make sure the file extension is named correctly and that the file is encoded in the proper format.
Renaming sound.mp3 to sound.wav will trigger a SoundPool: Not Ready error.

Related

Unable to load MP3 file using kivy on Android

I have created a music player using kivy. it is working fine for MP3 songs on Linux.
But when I am converting that into APK file using buildozer, then it is giving error that unable to load the file.
I am using sound loader of kivy to play the files.
This is working fine for .wav file and .ogg file. Error is coming only for MP3 files.
Any suggestions will be helpful.
Thanks in advance
Kivy only loads wav and ogg files on Android. Also make sure...
You load the sound file with kivy.core.audio.SoundLoader.load
You check if <SOUND_FILE_VARIABLE>: before you change the state of the sound because if the file doesn't exist or Kivy couldn't load the file, the sound file variable would be None
If the file is too long, the audio might be glitchy on Android.

Android mediaplayer getDuration() returns 0 for some mp3 files

I have a large collection of mp3 files on my server and i'm using android media player for playing them. The problem is for almost all of them getDuration() method returns 0. I uploaded sample mp3 file and put it somewhere on my server. mediaplayer works perfectly fine with that file!!
I can't understand what's the different. My knowledge about audio files is very limited. Can anyone give me a suggestion what to do?
can I somehow modify mp3 files on my server so mediaplayer can read the metadata?
BTW this problem occurs only on Android. My links on google chrome are fine. and google shows the duration of file right from the beginning of playing when only small percentage of file is downloaded.
We finally fixed this issue by replacing our web server. We replaced tomcat with apache and it fixed the issue. I don't exactly know why

Android: is there a way to buffer following mp3 file while playing current mp3?

I keep many mp3 files on a server to be able to receive them in my Android application. I am streaming mp3 files one after the other. My problem is that I want to already buffer the next mp3 file while playing the current mp3 file.
I tried it with already downloading the next mp3 file in cache while playing the first one. But the problem is that when the first mp3 file is done playing, the second mp3 file may not be fully downloaded (which can easily happen on a 2g connection). The player will then initialize the part of the mp3 file which is downloaded and the player will play only that part of the downloaded files which is initialized (please correct me if I'm wrong). This causes corrupt files and it is not good performance at all.
Please help me. Thanks in advance.
For the file that you want to buffer, can you create a second MediaPlayer instance using MediaPlayer create (Context context, Uri uri), but not calling .start(), and then use setNextMediaPlayer (MediaPlayer next), to queue this second player to start playing when the first one is finished?

Kivy Play Audio Not Working

I'm attempting to run Kivy's audio example found here. The specific example is this:
sound = SoundLoader.load(filename='test.wav')
if not sound:
# unable to load this sound ?
pass
else:
# sound loaded, let's play!
sound.play()
When attempting to play any .wav file in my directory however, I just hear a click or pop noise. I've tried with different .wav files and am experiencing the same problem. I've also attempted to print out the length of the sound by using the length function, but it returns 0 for some reason. Any feedback or input from you guys? Thanks again.
Can't say just looking at the snippet above how you've implemented it in your Application or what's wrong.
There is a more elaborate example should be in the examples directory under your Kivy install directory that should clear up how to use SoundLoader.
Hope that helps.

Android Media player from file stored in memory

i have this problem, i create a app, in this app i record audio ogg file, i store file in memory (i see the file using DDMS) ,
when i wont to play the file audio i have a error
in this link you can see the source
main:
http://pastebin.com/PWE9FsxT
android manifest:
http://pastebin.com/p39J1Y6i
logcat
http://pastebin.com/ktyFWPXq
please help me
Best Regads
Antonio
This error comes because sometimes mediaplayer is not ready , put a condition before playing a
sound so that sound will play when media player is completely released .

Categories

Resources