Search code examples
androidnullpointerexceptionmedia-playerprepare

mediaPlayer prepare nullpointer exception


it's realy rare error for me but.. It's error. Can't understand why. error just on line

mp.prepare();

from logcat :

  Caused by: java.lang.NullPointerException
            at myapp.activity.com.myApp.media(myApp.java:281)
            at myapp.activity.com.myApp$showLogotype.doInBackground(myApp.java:397)
            at myapp.activity.com.myApp$showLogotype.doInBackground(myApp.java:1)
            at android.os.AsyncTask$2.call(AsyncTask.java:185)
            at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305

Someone can explain me :( ?

Im using asynctask for prepare and load all datas and showing logo while my app reading datas and preparing for mediaPlayer( in logcat : mediaPlayer.prepare() getting 5-10 seconds) ) But im sometimes have this realy rare error for me(cos i can't understand how to get this error and he is realy rare for me)

Please explain me if anyone know :( or please< tell me how to fix this :( code of function :

 public void media() throws IllegalArgumentException, IllegalStateException, IOException
    {

        mp = new MediaPlayer();
        mp.setDataSource(stream);
        mp.prepare();

    }

Regards,Peter. Sorry for my bad english, hope u understand me


Solution

  • Can't catch this problem. I manualy catch and solve for some problem. I think media player have a bug .. .and this problem not fixing.