So I have set up the following code to pick a song from internal memory and play it.
Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Audio.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(intent, 10);
My onActivityResult:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(resultCode == RESULT_OK){
Uri uriSound = data.getData();
play(this, uriSound);
}
}
and finally my play method: private void play(Context context, Uri uri) {
MediaPlayer mip = new MediaPlayer();
try {
mip.setDataSource(context, uri);
mip.prepare();
mip.start();
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
but when I run this I keep getting the following error:
java.io.IOException: setDataSource failed.: status=0x80000000
I couldnt find a working solution anywhere. Any ideas?