I\'ve been really banging my head against the table trying to get the MediaPlayer class to try to play h.264-encoded videos on Android 2.1. My code is rather simple:
<
This is my solution:
MediaPlayer mediaPlayer = new MediaPlayer();
FileInputStream fis = null;
try {
File directory = new File("android.resource://com.example.myapp/raw/");
fis = new FileInputStream(directory);
mediaPlayer.setDataSource(fis.getFD());
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mediaPlayer.prepare();
} finally {
if (fis != null) {
try {
fis.close();
} catch (IOException ignore) {
}
}
}