In MediaPlayer.create method an id to a Raw file can be used but how to use that in setDataSource method?
Refer to the source android.media.MediaPlayer
AssetFileDescriptor afd = context.getResources().openRawResourceFd(resid);
if (afd == null) return;
mediaPlayer.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength());
afd.close();
You may want to add try-catch to the block.