I need to get the full path to a file somewhere on the phone (any location) and play it with MediaPlayer.
ive heard of using a file chooser for Android (by launching an
Some points:
prepare()
twice (once in the constructor and the other explicitly). That could be one of the reasons that the IllegalStateException
is thrown. Also, is the file that you are trying to play inside the application? If so, why are you trying to create a stream? If the file is already within the application (and within /res/raw
, you could try and save yourself the hassle of using prepare()
by creating the mediaplayer object like so:
mediaplayer = new MediaPlayer.create(this, R.raw.resource-name here);
The create function calls prepare()
within.
3. You can also try and use the reset()
function if any one of the stages in the MediaPlayer fails resulting in the MediaPlayer object entering the error state. Using reset()
would bring it back to Idle state.
4. The last time I had that error status=0x1
message, it turned out that I had not had the correct permissions set for the files (external storage etc. in Manifest) and some files placed in incorrect folders. You may also want to take a look at that.
Let me know in case that does not work,
We can try something else.
Sriram.