Hi,

i have an alarm clock app that uses mediaPlayer to play the audio.
I'm creating and starting the mediaPlayer in the Activity's onCreate
like so:

alarmPlayer = MediaPlayer.create(this, musicResId);
alarmPlayer.setVolume(masterVolume, masterVolume);
//masterVolume here is zero
alarmPlayer.setLooping(true);
alarmPlayer.start();
long period = timeIncrementReached;
// this is the number of millis to play the music at a certain volume
before increasing it
timer = new Timer();
AlarmVolumeIncreaser increaser = new AlarmVolumeIncreaser();
 timer.schedule( increaser, 0, period);

AlarmVolumeIncreaser is a runnable:

class AlarmVolumeIncreaser extends TimerTask
{
@Override
public void run()
        {masterVolume += .01f;
if(masterVolume>=1.0f)
                                masterVolume=1.0f;
                //Log.v("FLOWMASTER","masterVolume: "+masterVolume);
                if(masterVolume<1.0f)
                {
                        alarmPlayer.setVolume(masterVolume, masterVolume);
                }
        }


    }

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to