Greetings,
We have several Samsung phones running on Android 10 and our app uses the MediaPlayer to play a background sound file. The issue we are experiencing involves the volume the MediaPlayer plays the sound file. It fluctuates. Randomly it get quite loud for a duration of a few seconds and could last a minute or so. Other installed apps on the phone that produce sound will also play above their normal volume only when our app is playing the background sound. If we stop our app from playing the sound the sound from the other apps return to normal.
Could this be also be a compatibility issue with Android 10?
Heres the coding we use to play the sound in our app.
The volume for the above coding is stored using KVS when the user adjusts a slider view as shown in the following coding.
What additional coding will I need to add that will stop the MediaPlayer from randomly changing the volume of the sound file being played? The logs don't show any errors and using log statements shows the volume number never changes unless the user adjusts the slider.
Thanks.
We have several Samsung phones running on Android 10 and our app uses the MediaPlayer to play a background sound file. The issue we are experiencing involves the volume the MediaPlayer plays the sound file. It fluctuates. Randomly it get quite loud for a duration of a few seconds and could last a minute or so. Other installed apps on the phone that produce sound will also play above their normal volume only when our app is playing the background sound. If we stop our app from playing the sound the sound from the other apps return to normal.
Could this be also be a compatibility issue with Android 10?
Heres the coding we use to play the sound in our app.
B4X:
Sub tmrForCrickets_Tick
If MediaPlayerCrickets.IsPlaying = False Then
' When a scheduled song has started this number will come from the schedule timer.
' When a scheduled song is not playing, it's number comes from the database which
' will have the song number selected by the user.
'---------------------------------------------------------------------------------
If intSongNumberSelected = 0 Then
intSongNumberSelected = kvs.Get("CurrentSongSelected")
End If
If blnAsongIsPlaying And MediaPlayerCrickets.IsPlaying = False Then
MediaPlayerCrickets.Load(File.DirAssets, _
kvs.Get("Song" & intSongNumberSelected & "Creature0FileName"))
MediaPlayerCrickets.SetVolume( _
kvs.Get("Song" & intSongNumberSelected & "Creature0Volume"), _
kvs.Get("Song" & intSongNumberSelected & "Creature0Volume"))
MediaPlayerCrickets.Play
End If
End If
End Sub
The volume for the above coding is stored using KVS when the user adjusts a slider view as shown in the following coding.
B4X:
Sub B4XSeekBarVolume_TouchStateChanged (Pressed As Boolean)
kvs.put( _
"Song" & intCurrentSongSelected & _
"Creature" & intCurrentCreatureSelected & "Volume", B4XSeekBarVolume.Value / 100)
If ServiceModule.blnAsongIsPlaying Then
CallSubDelayed(ServiceModule, "CancelTheSong")
CallSubDelayed(ServiceModule, "PlayTheSong")
If ServiceModule.blnScheduleIsPlayingSong Then
CallSubDelayed(ServiceModule, "CancelSleepTimer")
Else
CallSubDelayed(ServiceModule, "StartSleepTimer")
End If
End If
ToastMessageShow("Volume now set at " & B4XSeekBarVolume.Value & "%.", False)
End Sub
What additional coding will I need to add that will stop the MediaPlayer from randomly changing the volume of the sound file being played? The logs don't show any errors and using log statements shows the volume number never changes unless the user adjusts the slider.
Thanks.