Android Question Sound is Playing

red30

Well-Known Member
Licensed User
Longtime User
B4J has a library for audio playback called "AudioClip". With this library I can control whether the sound is playing now.
B4X:
        If Sound.isPlaying=False Then
            Sound.Play
        End If
Is there something similar in B4A? I am using the "SoundPool" library. I need to play the sound in a loop, but I do not know when the playback stopped to play the next sound. How can I do this in B4A?
 

stevel05

Expert
Licensed User
Longtime User
If you want to play the same sound looped, then you can set this with the play method.

Android Soundpool doesn't have an isPlaying method. If you want to play a different sound when one has finished, there is a way you can get the duration of the file to set a timer or use sleep to wait until the current sound has finished to play the next sound. You will need to use JavaObject with the MediaMetadataRetriever class. See: https://developer.android.com/reference/android/media/MediaMetadataRetriever
 
Last edited:
Upvote 0
Top