Can you tell me if it's possible to queue up and play the sound files in MediaPlayer from a list object just like you can do with the ExoPlayer? I'm asking because we had to change our apps that play sounds from the ExoPlayer to the MediaPlayer because customers are updating their Samsung phones to the current version of Android version 11 which we found the hard way that the Samsung version of Android 11 does not play nicely with the ExoPlayer. It has something to do with the new way Samsung is handling battery optimising. The customers are all reporting their apps were randomly not running when their screens are turned off and also when they unplug their phones from the charger. Our solution in most of the apps was to use MediaPlayer because for some reason unknown to us is not affected by that version of Android. One of our apps does need to play 5 different sound files one after the other which was previously working with the ExoPlayer. I looked throughout the posts and did not see a code sample showing how to queue up the sound files to play on after the other like ExoPlayer can do it.
For example, I would like to add .CreateFileSource but MediaPlayer doesn't have that one as a choice.:
For those who want to see how I did it, here's the sub routines I added to get the loaded list to play each sound file one after the other.
Sample coding of how I added a sound file name into the list.:
lstPlayerSources.Add("chime.mp3")
I call this PlaySoundFilesInTheList after I finish adding a string with the sound file names into the list:
Sub PlaySoundFilesInTheList
MediaPlayerForChimes.Load(File.DirAssets, lstPlayerSources.Get(0))
MediaPlayerForChimes.SetVolume( kvs.Get("MasterVolume"), kvs.Get("MasterVolume"))
MediaPlayerForChimes.Play
End Sub
Sub MediaPlayerForChimes_Complete
lstPlayerSources.RemoveAt(0)
If lstPlayerSources.Size > 0 Then
PlaySoundFilesInTheList
End If
End Sub