Android media player error (38,0)

android multimedia programs, mediaplayer (-38, 0) error occurs when mediaplayer is called when mediaplayer is not synchronized (Prepared), or getDuration method is called.

A good solution is to set up the OnPreparedLisnter listener:

MediaPlayer.OnPreparedListener preparedListener = new MediaPlayer.OnPreparedListener() {

    public void onPrepared(MediaPlayer mp) {
        total = mp.getDuration();// 总时长

This ensures that the start and getDuration methods are called after prepare.

Read More: