Nick Burton wrote: > Howdy all, this is a problem faced by an Android Australia group > member. Since we're just starting out I've reposted here to get him a > solution. Any help would be appreciated. Kind regards, Nick. > > ---------- Forwarded message ---------- > > hey guys, > > i got a bit a code in a resource utility class: > static public void playSound(Context ctx, int resId) { > > try { > MediaPlayer mp = MediaPlayer.create(ctx, > resId); > mp.setOnErrorListener(mediaErrorListener); > mp.start(); > } catch (Exception e) { > Log.e(LOG_TAG, "unable to play sound", e); > } > } > > static public class MediaErrorListener implements > MediaPlayer.OnErrorListener { > @Override > public boolean onError(MediaPlayer mp, int what, int > extra) { > Log.e(LOG_TAG, "unable to play sound what:(" + > what + ") extra:(" + > extra + ")"); > return false; > } > } > > its been working fine. but i just tried it on a long instructional mp3 > file (10min) & 7MB and it stops after 20sec.
Can you define "stops"? In other words, does it bring up an error dialog? If so, what does adb logcat (or DDMS or the DDMS perspective in Eclipse) show you for a stack trace? You might want to check out logcat anyway, even if it does not display a dialog -- OpenCORE (the multimedia engine) seems to have a tendency to log errors at warning level and not raise them all the way up to where we in Java code can catch them. If you see "PV..." messages around the time it stops, those are probably related. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy Android Development Wiki: http://wiki.andmob.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Beginners" group. To post to this group, send email to android-beginners@googlegroups.com To unsubscribe from this group, send email to android-beginners-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -~----------~----~----~----~------~----~------~--~---