views:

18

answers:

0

Hi I have some weird problem with mediaplayer in android version less then 2.2. I made a game where I do some button clicks and if is answer OK then go to this method and play some sound, it play great on android 2.2 but on minor android version it show error after 7-8 Right answers ???

I have some code sample that works fine on android version 2.2
this is code:

private void msgImgOK()
{
 try {
 mp=MediaPlayer.create(play.this,R.raw.nice);
 if(mp.isPlaying())

mp.stop(); // mp.release();

mp.prepare(); } catch (IllegalStateException e) {

msgInfo(e.getMessage()); //e.printStackTrace(); } catch (IOException e) { msgInfo(e.getMessage()); //e.printStackTrace(); } mp.start(); }

Is there any special rules for using a MediaPlayer class in android OS version less than 2.2 ??

And this is LogCat Error :

10-26 16:19:49.861: WARN/dalvikvm(261): threadid=3: thread exiting with uncaught exception (group=0x4001b188) 10-26 16:19:49.871: ERROR/AndroidRuntime(261): Uncaught handler: thread main exiting due to uncaught exception 10-26 16:19:49.883: ERROR/AndroidRuntime(261): java.lang.NullPointerException 10-26 16:19:49.883: ERROR/AndroidRuntime(261): at com.zire.waic.playeasy.msgImgOK(playeasy.java:196) 10-26 16:19:49.883: ERROR/AndroidRuntime(261): at com.zire.waic.playeasy.correct(playeasy.java:175) 10-26 16:19:49.883: ERROR/AndroidRuntime(261): at com.zire.waic.playeasy.access$1(playeasy.java:170) 10-26 16:19:49.883: ERROR/AndroidRuntime(261): at com.zire.waic.playeasy$1.onClick(playeasy.java:103) 10-26 16:19:49.883: ERROR/AndroidRuntime(261): at android.view.View.performClick(View.java:2364) 10-26 16:19:49.883: ERROR/AndroidRuntime(261): at android.view.View.onTouchEvent(View.java:4179) 10-26 16:19:49.883: ERROR/AndroidRuntime(261): at android.widget.TextView.onTouchEvent(TextView.java:6534) 10-26 16:19:49.883: ERROR/AndroidRuntime(261): at android.view.View.dispatchTouchEvent(View.java:3709) 10-26 16:19:49.883: ERROR/AndroidRuntime(261): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:883) 10-26 16:19:49.883: ERROR/AndroidRuntime(261): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:883) 10-26 16:19:49.883: ERROR/AndroidRuntime(261): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:883) 10-26 16:19:49.883: ERROR/AndroidRuntime(261): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:883) 10-26 16:19:49.883: ERROR/AndroidRuntime(261): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:883) 10-26 16:19:49.883: ERROR/AndroidRuntime(261): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:883) 10-26 16:19:49.883: ERROR/AndroidRuntime(261): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659) 10-26 16:19:49.883: ERROR/AndroidRuntime(261): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107) 10-26 16:19:49.883: ERROR/AndroidRuntime(261): at android.app.Activity.dispatchTouchEvent(Activity.java:2061) 10-26 16:19:49.883: ERROR/AndroidRuntime(261): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643) 10-26 16:19:49.883: ERROR/AndroidRuntime(261): at android.view.ViewRoot.handleMessage(ViewRoot.java:1691) 10-26 16:19:49.883: ERROR/AndroidRuntime(261): at android.os.Handler.dispatchMessage(Handler.java:99) 10-26 16:19:49.883: ERROR/AndroidRuntime(261): at android.os.Looper.loop(Looper.java:123) 10-26 16:19:49.883: ERROR/AndroidRuntime(261): at android.app.ActivityThread.main(ActivityThread.java:4338) 10-26 16:19:49.883: ERROR/AndroidRuntime(261): at java.lang.reflect.Method.invokeNative(Native Method) 10-26 16:19:49.883: ERROR/AndroidRuntime(261): at java.lang.reflect.Method.invoke(Method.java:521) 10-26 16:19:49.883: ERROR/AndroidRuntime(261): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) 10-26 16:19:49.883: ERROR/AndroidRuntime(261): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 10-26 16:19:49.883: ERROR/AndroidRuntime(261): at dalvik.system.NativeStart.main(Native Method)