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.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…