how to get the sound fade in functionality in alarm application using media player in android -
Hello I am new to Android. I am developing an application with alarm functionality here to give me sound fade in functionality I'm using media player to open ringtone for alarm. Here is my code for playing alarm sound
try {if (mp == null) {System.out.println ("------- mp" is now zero - -------- "); Uri Mayuri = Uri.Pars ("android.resource: //com.android.crazy/raw/airtel"); Mp = MediaPlayer.create (alarm. This, myURI); } Mp.setDataSource (songName); Mp.prepareAsync (); Mp.setLooping (true); } Hold (exception e) {e.printStackTrace (); } Mp.start (); Here I have to give sound Fadin functionality Please advise me how to insert sound fade for any particular amount like 5 minutes
Thanks in advance < / Div>
You can use this method:
set volume (float left volumes, right volume Float); To create a "feed in" effect, you will just start with zero and keep it at a slightly higher interval. In this way, some things will increase the volume of half to 5% of each other
last handler H = new handler (); Float leftVol = 0f; Float right = 0f; Runnational enhancement = new Runnabal () {Public Zero Run () {mp.setVolume (leftVol, rightVol); If (leftVol> 1.0f) {leftVol = .05f; RightVol + = .05f; H.postDelayed (Growth, 500); }}}; H.post (increaseVol); If you change into the remaining wov and right wal then how much each tick can be increased if inside the statement. and how long you can change each tick by changing 500 parameters in the post.
Comments
Post a Comment