Page 1 of 1

Help on playing a sound

Posted: Mon Jun 13, 2011 9:48 am
by DougN
Hi,

I'm tearing my hair out trying to play a simple sound on an iPhone app. I've used Rev for a while, but this is my first experience on the iPhone. I've tried using the code referenced in the forums, but just can't get it to work. I hope you generous folks can help.

Here's my script, on a button:

Code: Select all

on mouseup
   play playspecialfolderpath(engine) & "/sounds/pleaseplay.aif"
end mouseup


Here's the Finder view of the pieces of the app, showing how the one sound "pleaseplay.aif" is located in a "sounds" folder:

Image

When I set the standalone application settings, I ask LiveCode to include all the files in the "sounds" folder:

Image

After I build the project, if I choose "Show Package Contents" I can see clearly that the app package includes the sounds folder and the specific sound file:

Image

The app loads fine onto the iPhone. But when I click the "Begin" button, no sound. I've tried most permutations of naming, moving files, etc. with no luck. Am I missing something basic here, or is something going on with my build that I'm not understanding?

Thank you!
Doug

Re: Help on playing a sound

Posted: Mon Jun 13, 2011 10:52 am
by Klaus
Hi Doug,

there is one "play" to much and you need to use parenthesis and QUOTES!
Just like written in the docs!
...
## BAD:
## play playspecialfolderpath(engine) & "/sounds/pleaseplay.aif"

## Good:
play (specialfolderpath("engine") & "/sounds/pleaseplay.aif")
...
:D


Best

Klaus

Re: Help on playing a sound

Posted: Mon Jun 13, 2011 12:16 pm
by Mark
Hi Doug,

This works for me:

Code: Select all

on mouseUp
     set the itemdel to slash
     set the directory to item 1 to -2 of the effective filename of this stack
     play "ding.wav"
end mouseUp
I have added the sound file as a non-stack file to be included with the standaline (see standalone settings). I also made sure to have a genuine, uncompressed WAVE file (couldn't fine an AIFF file that quickly).

Kind regards,

Mark

Thank you

Posted: Mon Jun 13, 2011 8:11 pm
by DougN
Thanks for the help -- sometimes outside eyes can be so helpful. I really appreciate the quick, helpful responses.