Help on playing a sound

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
DougN
Posts: 20
Joined: Wed Mar 04, 2009 4:09 am

Help on playing a sound

Post 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
Klaus
Posts: 14325
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Help on playing a sound

Post 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
Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Help on playing a sound

Post 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
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
DougN
Posts: 20
Joined: Wed Mar 04, 2009 4:09 am

Thank you

Post by DougN »

Thanks for the help -- sometimes outside eyes can be so helpful. I really appreciate the quick, helpful responses.
Post Reply