Audio playback problems
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Audio playback problems
I can't get any audio clips to play in LiveCode apps. I'm ready to tear my hair out, because it looks as if it ought to be simple.
I'm using wav files on a PC for a desktop application, and I followed the basic instructions on the LiveCode site.
For instance, I tried:
on mouseUp
play audioClip "path/filename.wav"
end mouseUp
I also imported the clip (import as control), then used this code:
on mouseUp
play "filename.wav"
end mouseUp
I used several clips, all of which play just fine outside of LiveCode. (So no, my computer isn't muted.)
I also tried with a player object. No joy.
Clicking has an effect -- in the case of buttons, they stay depressed for the length of the sound clip -- but you can't actually hear the sound.
Is there a fix for this? Does audio simply not work in LiveCode anymore? (I downloaded a test stack posted to the "How to Play a Sound" thread from March 2014 -- can't post a link, sorry -- and THAT sound won't play, either.)
I'm using wav files on a PC for a desktop application, and I followed the basic instructions on the LiveCode site.
For instance, I tried:
on mouseUp
play audioClip "path/filename.wav"
end mouseUp
I also imported the clip (import as control), then used this code:
on mouseUp
play "filename.wav"
end mouseUp
I used several clips, all of which play just fine outside of LiveCode. (So no, my computer isn't muted.)
I also tried with a player object. No joy.
Clicking has an effect -- in the case of buttons, they stay depressed for the length of the sound clip -- but you can't actually hear the sound.
Is there a fix for this? Does audio simply not work in LiveCode anymore? (I downloaded a test stack posted to the "How to Play a Sound" thread from March 2014 -- can't post a link, sorry -- and THAT sound won't play, either.)
Re: Audio playback problems
Hi JSH,
You have to use the name of an audioclip to play it
And the filename to playing an audio file
Best regards
Jean-Marc
You have to use the name of an audioclip to play it
Code: Select all
play audioClip "gorille_2.wav"
Code: Select all
answer file "Open a sound file"
if it = empty then exit mouseup
play it
Jean-Marc
https://alternatic.ch
Re: Audio playback problems
The filepath should work, it is supported. Are you sure it's correct? Try this to get the actual file path so you can check:
The message box will show you the path, and you can compare that to your script to see if they match. Remember that relative file paths always begin at the defaultFolder, and that isn't always where your stack lives.
LC natively supports a very limited number of audio formats for embedded sounds, which must be uncompressed audio only. Not all .wav files are uncompressed.For that reason it's usually better to use a player object, which supports more formats. If the above doesn't fix it, try different audio formats to see which ones are supported by the player in LC. (Someone else may remember exactly which those are.)
Code: Select all
answer file "Choose audio:"
put it
LC natively supports a very limited number of audio formats for embedded sounds, which must be uncompressed audio only. Not all .wav files are uncompressed.For that reason it's usually better to use a player object, which supports more formats. If the above doesn't fix it, try different audio formats to see which ones are supported by the player in LC. (Someone else may remember exactly which those are.)
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Audio playback problems
Thanks for the suggestions.
Jean-Marc, "filename.wav" was just a placeholder for this example -- I did use the actual file names, i.e. "flying.wav" -- but that was a good thought.
Jacqueline, I tried your recommendation to check the path, and it does match up with my script. I've also tried using player objects, and those haven't worked for me, either. (For instance, I set the player object's source as the audio clip by clicking on the folder and choosing it, so there would be no problem with the path. I tried a wav file and an aiff file.) I don't think the sound clips I've used are compressed, but if they are, a player object should be able to handle it, right?
Jean-Marc, "filename.wav" was just a placeholder for this example -- I did use the actual file names, i.e. "flying.wav" -- but that was a good thought.
Jacqueline, I tried your recommendation to check the path, and it does match up with my script. I've also tried using player objects, and those haven't worked for me, either. (For instance, I set the player object's source as the audio clip by clicking on the folder and choosing it, so there would be no problem with the path. I tried a wav file and an aiff file.) I don't think the sound clips I've used are compressed, but if they are, a player object should be able to handle it, right?
Re: Audio playback problems
I think I may have found the problem -- it's my computer. I tried the stack on a Mac and the sounds play.
No idea why they won't work on my PC, since my PC will play the clips in Windows Media Player.
No idea why they won't work on my PC, since my PC will play the clips in Windows Media Player.
Re: Audio playback problems
Do they need QuickTime? It's turned off by default as of LC 7.x. Does it work if you set the dontUseQT to false?
And yes, a player should be able to handle compressed audio formats.
And yes, a player should be able to handle compressed audio formats.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Audio playback problems
I don't think the audio clips I'm using require QuickTime, but that's a thought. I tried putting "set dontUseQT to false" in the stack code. Assuming I did that right, it didn't make a difference -- still no sound on the PC version.
Very weird. I don't have another PC immediately at hand, but at some point I'll test it on another one to see if it's just my PC that's the problem.
Thanks!
Very weird. I don't have another PC immediately at hand, but at some point I'll test it on another one to see if it's just my PC that's the problem.
Thanks!
-
- VIP Livecode Opensource Backer
- Posts: 366
- Joined: Mon Jun 10, 2013 1:32 pm
Re: Audio playback problems
Hi,
I have just spent 6 hours trying to do something as simple as playing a 2 second soundclip on ANDROID and have failed miserably.
It works perfectly on desktop using
the above works for a simple embedded wav file
The below doesn't show all the different permutations I tried but vthe basics were ...
I have also tried the above with an mp3 just in case.
on startup the first thing I do is ....
so I KNOW the file is there.
I also tried to play from the engine special folder and the documents that I copied to (wav and mp3)
i have
read the documentation
read the questions on the forums
read stackoverflow
read the posts by the usual suspects (and some not usual suspects - the ones who pulled their hair out - I don't have any so thats a bonus)
I assumed maybe my Asus tablet was at fault so I ran it on my Acer Tablet
Then I thought maybe it's the 6.7 series livecode so I compiled on the latest 7.xx still no go
Can somebody UpLoad a program that plays anything at all on android - ANYTHING with the source and the apk file so I can test - I might even try and install on my Ipad - Just in case but the app is only going to run on Android so no point
other than to see if its a problem with LC
I tried standing on my head while whistling Dixie but I couldn't control the mouse
Gotta stop now its 9pm and I've been at this since about 3 pm
Regards Lagi
I have just spent 6 hours trying to do something as simple as playing a 2 second soundclip on ANDROID and have failed miserably.
It works perfectly on desktop using
Code: Select all
play audioclip ID 1054
the above works for a simple embedded wav file
The below doesn't show all the different permutations I tried but vthe basics were ...
Code: Select all
play audioclip "xxx.wav" -- With the audioclip imported onto the audioclip stack as id 1054
mobilePlaySoundOnChannel (specialFolderPath("Documents") & "/xxx.wav") , "current", "now"
create player "my player""
set the filename of player "my player" to specialFolderPath("Documents") & "/xxx.wav"
answer "playing " && ("AudioClip ")
play audioclip "xxx.wav"
I have also tried the above with an mp3 just in case.
on startup the first thing I do is ....
Code: Select all
if the environment is "mobile" then
put URL ("binfile:" & specialFolderPath("engine") & "/xxx.wav") into URL ("binfile:" & specialFolderPath("Documents") & "/xxx.wav")
if there is not a file (specialFolderPath("Documents")& "/xxx.wav") then
answer error "Sound xxx.wav is missing -- shoot the programmer"
end if
end if
I also tried to play from the engine special folder and the documents that I copied to (wav and mp3)
i have
read the documentation
read the questions on the forums
read stackoverflow
read the posts by the usual suspects (and some not usual suspects - the ones who pulled their hair out - I don't have any so thats a bonus)
I assumed maybe my Asus tablet was at fault so I ran it on my Acer Tablet
Then I thought maybe it's the 6.7 series livecode so I compiled on the latest 7.xx still no go
Can somebody UpLoad a program that plays anything at all on android - ANYTHING with the source and the apk file so I can test - I might even try and install on my Ipad - Just in case but the app is only going to run on Android so no point
other than to see if its a problem with LC
I tried standing on my head while whistling Dixie but I couldn't control the mouse

Gotta stop now its 9pm and I've been at this since about 3 pm
Regards Lagi
Re: Audio playback problems
Hi Lagi,
imported sounds are not supported on the mobile platform, so:
...
play audioclip ID 1234
## or
play "imported_sound.aif"
...
will not work!
When using PLAY on mobile, you need to omit the keyword "audioclip", so this should work:
...
play (specialFolderPath("engine") & "/xxx.wav")
...
If that does not work, make sure that Android actually supports the WAV format!
Best
Klaus
imported sounds are not supported on the mobile platform, so:
...
play audioclip ID 1234
## or
play "imported_sound.aif"
...
will not work!
When using PLAY on mobile, you need to omit the keyword "audioclip", so this should work:
...
play (specialFolderPath("engine") & "/xxx.wav")
...
If that does not work, make sure that Android actually supports the WAV format!
Best
Klaus
-
- VIP Livecode Opensource Backer
- Posts: 366
- Joined: Mon Jun 10, 2013 1:32 pm
Re: Audio playback problems
Hi Klaus
Ive tried the above from the engine and the documents folder with wav and mp3 . i've also checked the files exist after i copy to the documents folder and just before i play the file.
i've also made the call with and without parentheses. Still no Joy
Regards Lagi
p.s. The beep works 100%
Ive tried the above from the engine and the documents folder with wav and mp3 . i've also checked the files exist after i copy to the documents folder and just before i play the file.
i've also made the call with and without parentheses. Still no Joy
with apologies to John LennonWhen I was younger, so much younger than today
I never needed anybody's help to port in any way
But now these days are gone, I'm not so self assured
Problems with Android play are driving me up the wall
Help me if you can, I'm feeling down
And I do appreciate you Klaus being round
But all I want is Android play a simple sound
Won't you, please, please help me?
Regards Lagi
p.s. The beep works 100%
-
- Posts: 4
- Joined: Tue Sep 22, 2020 4:13 pm
Re: Audio playback problems
Hello all !
Has progress been made for you since last post, five years ago ?
For I am having the same problem here, running LiveCode Community under Linux.
Beep works fine, though.
Thanks
Fred
Has progress been made for you since last post, five years ago ?
For I am having the same problem here, running LiveCode Community under Linux.
Beep works fine, though.

Thanks
Fred