Android Question Setting volume to minimum

JakeBullet70

Well-Known Member
Licensed User
Longtime User
Hi all
I am trying to set the volume to a minimum level for MediaPlayer.
Here is the code below witch seems not to be working.

Is setting volume to 1 a problem? Is there a minimum level?
I have tried every channel and that has done nothing.

Ideas? Help... :)

B4X:
    Dim minLevel as int = 1
    Dim ph As Phone
    Dim channel As Int = ph.VOLUME_MUSIC     '--- use this audio channel
    Dim origVol As Int = ph.GetVolume(channel) '--- save current vol
    Dim nMax As Int    = ph.GetMaxVolume(channel) '--- max int of channel

    ph.SetVolume(channel, minLevel, False) '--- try and set to minimum level
    
    Log("max vol: " & nMax)
    Log("original vol: " & origVol)
    Log("after set vol: " & ph.GetVolume(channel))
        
    '--- play sound
    PlaySound("swipe.mp3") 
    
    '--- reset to previous volume
    ph.SetVolume(channel,origVol, False)
    return



Public Sub PlaySound(sfile As String)
    mp.Initialize2("mp")
    mp.Load(File.DirAssets,sfile)
    mp.Play
End Sub

Private Sub MP_Complete
    mp.Release
End Sub
 
Top