android MediaPlayer 报错start called in state 1是怎么回事?
澳门美高梅官网
澳门美高梅官网
当前位置 : 澳门美高梅官网 > 美高梅娱乐

android MediaPlayer 报错start called in state 1是怎么回事?

mediaPlayer报错start called in state 1 error-38,0是怎么回事
我调用start之前有prepare;
在onCreate里已经使用了initMediaPlayer

private void initMediaPlayer {

    try {
        File file = new FileEnvironment.getExternalStorageDirectory,"music.mp3";
        mediaPlayer.setDataSourcefile.getPath;
        mediaPlayer.prepare;
    } catch IOException e {
        e.printStackTrace;
    }
}

@Override
public void onClickView v {
    switch v.getId{
        case R.id.play:
            if !mediaPlayer.isPlaying
                mediaPlayer.start;
            break;
        case R.id.pause:
            if mediaPlayer.isPlaying
                mediaPlayer.pause;
            break;
        case R.id.stop:
            if mediaPlayer.isPlaying{
                mediaPlayer.reset;
                initMediaPlayer;
            }
    }

}

你有没有加 读取存储卡的权限?
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

栏目列表

广告位

澳门美高梅官网