MediaPlayer create method return null object Android

a 夏天 提交于 2019-12-13 00:47:35

问题


I followed many guides about the music player, but my problem is the create method because when i try to do start() the activity crash saying to me that musicplayer is null, here is the code:

MediaPlayer mediaPlayer;
mediaPlayer = MediaPlayer.create(CustomMediaPlayer.this, R.raw.aud_0101);
...
mediaPlayer.start();

the audio file is right inside the raw directory, so I don't know how could be the problem of this nullPointer, anyone have some idea?

来源:https://stackoverflow.com/questions/34881160/mediaplayer-create-method-return-null-object-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!