Android MediaPlayer.Create() Returns Null
Solution 1:
Your file uses WAVE 8,000Hz MP3 8 kbit/s format, while android supports only 8- and 16-bit linear PCM: http://developer.android.com/guide/appendix/media-formats.html.
Try fixing your file.
Solution 2:
It can happen that it returns null
because the device doesn't support playing audio i.e watch
.
To check if device supports MediaPlayer you can do a null check on MediaPlayer.create()
I found it on google santa-tracker app
Solution 3:
null
seems to be communicating that something went wrong. Since Google shows this as the first result for "android mediaplayer.create() returns null", my recommendation would be to go through your code and check
- if your device supports the format as indicated by Vasily
- if the file that you passed in actually exists or has already been created
In my case I had created an empty file before passing it to Mediaplayer.create
. This worked fine on my emulated device, but crashed on my personal device.
Post a Comment for "Android MediaPlayer.Create() Returns Null"