[Android]How to play music in bootanimation

<!-- lang: cpp -->
        sp<MediaPlayer> mPlayer=new MediaPlayer();
    status_t status;

    status = mPlayer->setDataSource("/system/media/bootanimation.mp3", NULL);


    mPlayer->setAudioStreamType(AUDIO_STREAM_BOOT);
    status = mPlayer->prepare();

    /*to play sound*/
    if (status == NO_ERROR) {           
        status = mPlayer->start();
    }



    if (mAndroidAnimation) {
        r = android();
    } else {
        r = movie();
    }

            /*to stop music*/
    if (status == NO_ERROR) {           
        mPlayer->stop();
        mPlayer->disconnect();       
    }

    /*to destructor mediaplayer, use feature of StrongPointer*/
    mPlayer = NULL;

你可能感兴趣的:([Android]How to play music in bootanimation)