cannot get app to play audio from sd

All your problems with Audio, Video and Images.

cannot get app to play audio from sd

Postby mardox » Sun Oct 31, 2010 6:58 pm

Hi!

I have started development of my first android app recently and have gotten myself into some trouble. the app consists of two parts, a note taking part and a diktation part. the note taking part is all done. after alot of hasstle i got my app to record on the press of a button and stop recording on the next press of the same button. so my app works except for 2 problems. the first being that when i use String dateName = String.format("%d-%d-%d-%d-%d",Calendar.MONTH,Calendar.DATE,Calendar.HOUR_OF_DAY,Calendar.MINUTE,Calendar.SECOND);
too name the diktation it returns the same string everytime (2-5-11-12-13) dont know why, this does so every recording overwrites the previous.

the second problem is that when using onlistitemclick method it does not play any audiofile and return error in logcat. here is the part of the code for the onlistitemclick method and the logcat.

10-31 13:32:21.892: ERROR/audio_input(120): VerifyAndSetParameter failed
10-31 13:32:24.782: DEBUG/dalvikvm(14483): GC_EXPLICIT freed 2040 objects / 168960 bytes in 62ms
10-31 13:32:26.442: DEBUG/dalvikvm(14686): GC_EXTERNAL_ALLOC freed 1450 objects / 96416 bytes in 42ms
10-31 13:32:26.472: DEBUG/dalvikvm(14686): GC_EXTERNAL_ALLOC freed 296 objects / 15280 bytes in 24ms
10-31 13:32:29.802: INFO/StagefrightPlayer(120): setDataSource('voicenotes/2-5-11-12-13')
10-31 13:32:29.802: ERROR/MediaPlayer(14686): error (1, -2147483648)
10-31 13:32:29.802: WARN/System.err(14686): java.io.IOException: Prepare failed.: status=0x1
10-31 13:32:29.812: WARN/System.err(14686): at android.media.MediaPlayer.prepare(Native Method)
10-31 13:32:29.812: WARN/System.err(14686): at com.android.demo.notepad3.Notepadv3.onListItemClick(Notepadv3.java:209)
10-31 13:32:29.812: WARN/System.err(14686): at android.app.ListActivity$2.onItemClick(ListActivity.java:321)
10-31 13:32:29.812: WARN/System.err(14686): at android.widget.AdapterView.performItemClick(AdapterView.java:284)
10-31 13:32:29.812: WARN/System.err(14686): at android.widget.ListView.performItemClick(ListView.java:3385)
10-31 13:32:29.812: WARN/System.err(14686): at android.widget.AbsListView$PerformClick.run(AbsListView.java:1696)
10-31 13:32:29.822: WARN/System.err(14686): at android.os.Handler.handleCallback(Handler.java:587)
10-31 13:32:29.822: WARN/System.err(14686): at android.os.Handler.dispatchMessage(Handler.java:92)
10-31 13:32:29.822: WARN/System.err(14686): at android.os.Looper.loop(Looper.java:123)
10-31 13:32:29.822: WARN/System.err(14686): at android.app.ActivityThread.main(ActivityThread.java:4627)
10-31 13:32:29.822: WARN/System.err(14686): at java.lang.reflect.Method.invokeNative(Native Method)
10-31 13:32:29.832: WARN/System.err(14686): at java.lang.reflect.Method.invoke(Method.java:521)
10-31 13:32:29.832: WARN/System.err(14686): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
10-31 13:32:29.832: WARN/System.err(14686): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
10-31 13:32:29.832: WARN/System.err(14686): at dalvik.system.NativeStart.main(Native Method)
10-31 13:32:29.832: ERROR/MediaPlayer(14686): start called in state 0
10-31 13:32:29.832: ERROR/MediaPlayer(14686): error (-38, 0)
10-31 13:32:29.832: ERROR/MediaPlayer(14686): Error (-38,0)
10-31 13:32:32.782: INFO/ActivityManager(163): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=0x10200000 cmp=com.fede.launcher/.Launcher }
10-31 13:32:32.802: INFO/GPSButton(163): Update State
10-31 13:32:32.802: DEBUG/ConnectivityService(163): getMobileDataEnabled returning true

Cursor p = mdiktationsDbHelper.fetchDate(id);
startManagingCursor(p);
String selection = p.getString(1);
MediaPlayer mp = new MediaPlayer();
try {
mp.setDataSource(String.format("voicenotes/%s",selection));
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
mp.prepare();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
mp.start();

all help is apreciated! thanks
mardox
Freshman
Freshman
 
Posts: 8
Joined: Sun Oct 31, 2010 6:44 pm

Top

Re: cannot get app to play audio from sd

Postby Kerbik » Wed Dec 01, 2010 8:33 am

Hello,
I'm not very sure, but what happens when you will change

from
mp.setDataSource(String.format("voicenotes/%s",selection));

to more exactly path ... like this

mp.setDataSource(String.format("/sdcard/voicenotes/%s",selection)); // depends where you have located your voicenotes folder...


I'm sorry, I'm in work so I can only tell you what i think I can't test it :( .

I hope i helped a little,
Kerbik.
Kerbik
Developer
Developer
 
Posts: 30
Joined: Fri May 28, 2010 6:06 am

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: Google Feedfetcher and 9 guests