Android Question Pause code while sound file plays

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Working on a route direction app that uses sound files.
To avoid a sound file being cut off due to a second sound file starting I need to stop that second sound file starting while the first one still runs.
ResumableSub doesn't solve this problem.
As the sound files have the naming of the actual spoken words I have solved it near enough like this:

B4X:
    If strDirection.Length > 0 Then
        Dim rs As ResumableSub = PlaySoundFile(File.DirRootExternal & "/PhonePats/Map_Directions", strDirection & ".m4a")
        Wait For (rs) Complete (bDone As Boolean)
    End If
    
    'default for Enums.iSoundFileDelayFactor = 140
    Sleep(strDirection.Length * Enums.iSoundFileDelayFactor) 'to avoid cutting off the sound due to the next sound file

Just wondering if there might be a better way to do this.

RBS
 
Top