B4J Question play wav ubonto using shell

mzsoft

Member
in ubonto we cant play sound with mediaplay.
so i want to play with shell command.
in terminal with command below i play wav.
B4X:
aplay /home/admins/tempjars/Record/11012023094449.wav
in shell i write this

B4X:
Dim path As String=    File.GetUri("/home/admins/tempjars/Record/11012023094449.wav","")
        
    Dim sh As Shell
    sh.Initialize("sh", "aplay", Array As String(path))
    sh.Run(2000)

but this error show

B4X:
aplay: main:834: audio open error: Host is down
 

teddybear

Well-Known Member
Licensed User
in ubonto we cant play sound with mediaplay.
so i want to play with shell command.
in terminal with command below i play wav.
B4X:
aplay /home/admins/tempjars/Record/11012023094449.wav
in shell i write this

B4X:
Dim path As String=    File.GetUri("/home/admins/tempjars/Record/11012023094449.wav","")
      
    Dim sh As Shell
    sh.Initialize("sh", "aplay", Array As String(path))
    sh.Run(2000)

but this error show

B4X:
aplay: main:834: audio open error: Host is down
Where is aplay? perhaps you need the fullpath of aplay as cmd, it looks like :

B4X:
sh.Initialize("sh", "/...fullpath.../aplay", Array As String(path))
 
Upvote 0

teddybear

Well-Known Member
Licensed User
Could you play it in terminal cmdline
B4X:
aplay /home/admins/tempja

if yes , you should use path instead of URI
B4X:
sh.Initialize("sh", "aplay", Array As String("/home/admins/tempjars/Record/11012023094449.wav"))
 
Last edited:
Upvote 0

mzsoft

Member
Could you play it in terminal cmdline
B4X:
aplay /home/admins/tempja

if yes , you should use path instead of URI
B4X:
sh.Initialize("sh", "aplay", Array As String("/home/admins/tempjars/Record/11012023094449.wav"))
yes i can run in linux terminal and play ok.
in shut another file play.
but in shell eeror show

B4X:
aplay: main:834: audio open error: Host is down
 

Attachments

  • shot.png
    shot.png
    45.6 KB · Views: 45
Upvote 0

teddybear

Well-Known Member
Licensed User
This code I have tested on my ubuntu. it works.
B4X:
Sub AppStart (Args() As String)
    Dim shl As Shell
    shl.Initialize("shl", "aplay", Array As String("/tmp/01.wav"))
    shl.WorkingDirectory = "."
    shl.Run(10000) 'set a timeout of 10 seconds
    StartMessageLoop 'need to call this as this is a console app.
End Sub


Sub shl_ProcessCompleted (Success As Boolean, ExitCode As Int, StdOut As String, StdErr As String)
    If Success And ExitCode = 0 Then
        Log("Success")
        Log(StdOut)
        Log("Result: " & StdErr)
    Else
        Log("Error: " & StdErr)
    End If
    ExitApplication
End Sub

If it does not work , try run it as root
 
Last edited:
Upvote 0

hatzisn

Well-Known Member
Licensed User
Longtime User
Open terminal and write the following then check if it works. Write this:

Rich (BB code):
sudo chmod -R o=rwx /home/admins/tempjars/Record
 
Upvote 0
Top