In Android ICS, the following code runs well in bootanimation_main.cpp
and the music can be heard when starting up the phone. But the same code does not work in Android JB. The music cannot be heard when starting up the phone, and the music must be very long so the music can be heard the last past [meaning unclear]. But when I run bootanimation in adb shell, the music can be heard.
int index;
MediaPlayer* mp = new MediaPlayer();
if (mp->setDataSource("/sdcard/bootup.mp3", NULL) == NO_ERROR) {
mp->setAudioStreamType(AudioSystem::ENFORCED_AUDIBLE);
mp->prepare();
}
AudioSystem::getStreamVolumeIndex(AudioSystem::ENFORCED_AUDIBLE, &index);
if (index != 0) {
mp->seekTo(0);
mp->start();
}