开发者

Progress Dialogs with Sound in Android

开发者 https://www.devze.com 2023-04-09 04:57 出处:网络
I have searched around for possible answers, but did not find one that came close to what I require.

I have searched around for possible answers, but did not find one that came close to what I require.

I am after creating a progress dialog in Android, the standard one with the spinning disk. However, what I want is for the dialog to play a loop开发者_如何转开发ed sound sample as it spins which stops when its dismissed.

How would you go about doing this?

All the best

Andrew.


When you first show() your ProgressDialog start a looping MediaPlayer.

    MediaPlayer mAlarmPlayer=MediaPlayer.create(this, R.raw.alarm_1);
    mAlarmPlayer.setLooping(true);
    mAlarmPlayer.start();

when you will dismiss() your ProgressDialog just call:

    mAlarmPlayer.stop();
    mAlarmPlayer.release();
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号