B4J Question question about Jshell

rdkartono

Member
Licensed User
Longtime User
Hi all,

I write a program with B4J, and here are some snippets :

public audio_playback_start as boolean = false
......

Sub AppStart (Args() As String)
.......
StartMessageLoop
End Sub

Sub TIMER1_Tick
.......
set_menu_ID(3111)
PlayWav(audiofiles.Get(audiofiles_testindex))
Do While audio_playback_start
Delay(1000)
Log("Audio_playback = "&audio_playback_start)
Loop
set_menu_ID(3110)
.........
end sub


Public Sub PlayWav(filename As String)
Dim js As Shell
audio_playback_start = False
js.Initialize("PLAYSOUND","aplay",Array As String("/audiofiles/"&filename))
js.Run(-1)
audio_playback_start = True
End Sub

Public Sub PLAYSOUND_ProcessCompleted(Success As Boolean, ExitCode As Int, StdOut As String, StdErr As String)
audio_playback_start = False
If Success AND ExitCode=0 Then
Log("Play alarm finish")
Else
Log(StdErr)
End If

End Sub


The question is :
variable audio_playback_start is set TRUE after calling PlayWav, and supposedly to set FALSE after shell processcompleted.

At TIMER1_tick function, i detect this variable, and wait until it become FALSE by using DO WHILE & LOOP, then continue to next steps.
The problem is, DO WHILE always detect audio_playback_start as TRUE.

Please advice a solution for this problem.

Thank you.
 
Top