Android Question smoothly ncrease and decrease a sound volume

hub73

Active Member
Licensed User
Longtime User
Hello.
i am searching how to automatically smoothly increase the sound volume at the start. And next smoothly decrease it at the end when you playing it with MediaPlayer play command.
For this i'm tring to use libs MediaPlayer, Phone and a timer. But I did not succeed with my code.
Have you some idea to help me ?
Many Thanks.
 

hub73

Active Member
Licensed User
Longtime User
yes, of course. I'm trying to simplify my problem inside a project and i will post it here.
 
Upvote 0

hub73

Active Member
Licensed User
Longtime User
This is a basic project to begin. i want automatically increase smoothly the sound volume when start playing. And next smoothly decrease the sound volume at end. The user set the volume. It must be transparent for the user.
 

Attachments

  • increase_decrease_sound.zip
    175.6 KB · Views: 181
Upvote 0

hub73

Active Member
Licensed User
Longtime User
so perhaps this :

B4X:
Sub Button_play_Click
    
    Dim v As Float
    Dim i As Float
    
    MP.Load(File.DirAssets, "jingle.mp3")
    Timer_track.Enabled = True
    Seekbar_track.Value = 0
    MP.Play
    
    v = Seekbar_volume.Value / 100
    
    For i = 0 To v*10 Step 0.1
        MP.SetVolume(i, i)
        Sleep(10)
    Next
    
End Sub

/CODE]
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…