Android Media player from file stored in memory - android

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 .

Related

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?

MediaPlayer can not play mp3 from app data directory

I create an App which download a mp3 file and save it in app data directory and play it using android MediaPlayer class , the problem is, this code work on some device and not work on others, for example I noticed the device with SDK 10 and lower can't play it.
the code I use is very simple
mp = MediaPlayer.create(Sounds.this, Uri.fromFile(f));
mp.start();
I would appreciate any help.

Notifying native music player that a music file is added to storage

How to notify the android that a mp3 file is added to the storage and let it display the file inside the music app? I am converting a video to audio, but the file is not displaying in the music player. Now, I moved the file from one folder to another using File Manager. Now the music player is displaying the file. Shall I notify the android that a media file is added so that the music player can display it??
Probably you're looking for Media ScannerConnection Class. Just have a look in the developer site here:
MediaScannerConnection

Libgdx audio wav file not playing soundpool not ready?

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.

Categories

Resources