@Override public void onPrepared(MediaPlayer mp) { try{ mediaPlayer.setDisplay(surfaceHolder); mediaPlayer.start(); videoControllerView.start(); layoutProgressBar.setVisibility(View.INVISIBLE); RequestsRB.putStartWatchingVideo(this, mCourseId, mToken, mLessons.get(currentVideoNum).getId()); }catch (Exception e){ Log.e("WatchVideoActivity=onPrepared", "ERRROR" + ""); if (mediaPlayer==null) Log.e("WatchVideoActivity=onPrepared", "DA1" + ""); if (mp==null) Log.e("WatchVideoActivity=onPrepared", "DA2" + ""); } } 

I got the NullPointer in line

if (mediaPlayer==null) Log.e("WatchVideoActivity=onPrepared", "DA1" + "");

Roughly speaking mediaPlayer is null. And mp is not null. Duck because this is the same thing. What kind of garbage)).

Explain to me please

By the way mediaPlayer has public static

    1 answer 1

    Duck because this is the same thing.

    Well, firstly, this is not the same thing. mp is passed as a parameter to this function redefined by you and most likely not null, since this procedure is called when the player is ready. But mediaPlayer is not clear what it is and why. If this is a class field, then it is not initialized before calling this procedure and you should look at the code above, where it should have been initialized and how.

    • It is initiated. Media player calls onPrepared. via prepareAsync - Andro