Your code seems okay as far as I can tell. I'm guessing the path is not getting 
set correctly. Are you running this in the simulator or on a device?

One really quick way to verify the path of a file, especially if you're running 
in the simulator, is to simply place an answer command right before the call to 
mobilePlaySoundOnChannel to check the existence of the file you're trying to 
play. So something like:

answer there is a file tSoundFile

This will return true if the file exists, false otherwise. If your app is built 
for a device and you want to make sure the file are copying into the bundle 
correctly, in the Finder, right click on the bundle and choose Show Package 
Contents. Your files will either be right inside that folder or inside a sub 
folder. So just make sure to set the path accordingly. You can also verify the 
path by looking at the path as it's listed in Standalone Application Settings. 
If there are any folder names as part of the path, those folders will be 
created inside your app bundle and need to be included when building paths for 
the sound files.

So if you've verified the path and things are still not working, the only other 
thing I can think of is that you've got files that are not compatible with iOS 
for whatever reason, though I believe those file types are.

Chris


On Jun 20, 2012, at 12:44 PM, Roger Guay <i...@mac.com> wrote:

> I'm sorry, I forgot to include the Subject 
> 
> Thanks, Chris. I tried a number of variations of your suggestion to no avail!
> 
> I tried these code snippets:
> 
>               put the engine folder & "/assets/mySnd.caf" into tSoundFile
>    or         put specialFolderPath("engine") & "/mySnd.caf" into tSoundFile
> 
>     mobilePlaySoundOnChannel tSoundFile, "current", "now"
> 
> I tried these for both wav and caf file formats, again all to no avail.
> 
> I copied sound files directly into the "non-stack files in the application" 
> of the Standalone Application Settings. I'm sure I'm doing something stupid 
> (again), but I can't figure it out. I would greatly appreciate any more help 
> you might provide.
> 
> BTW, you suggest verifying "that it's copying correctly in the app bundle". 
> How do I do that?
> 
> Thanks,
> Roger
> 
> 
> 
> 
> On Jun 20, 2012, at 10:00 AM, use-livecode-requ...@lists.runrev.com wrote:
> 
>> Message: 9
>> Date: Wed, 20 Jun 2012 08:38:58 -0600
>> From: Chris Sheffield <cmsheffi...@me.com>
>> To: How to use LiveCode <use-livecode@lists.runrev.com>
>> Subject: Re: Playing Sounds in iOS
>> Message-ID: <40ffff72-d477-42c7-bc36-0dc45ee0b...@me.com>
>> Content-Type: text/plain; CHARSET=US-ASCII
>> 
>> Roger,
>> 
>> When using mobilePlaySoundOnChannel, I've always had to build the full path 
>> to the file for it to work correctly. So if you've verified that it's 
>> copying correctly into the app bundle and, assuming it's not in a sub folder 
>> of the bundle, try something like this:
>> 
>> if the environment is "mobile" then
>> put specialFolderPath("engine") & "/mySnd.wav" into tPath
>> mobilePlaySoundOnChannel tPath, "current", "now"
>> else
>> play "mySnd.wav"
>> end if
>> 
>> Hopefully that'll work for you. If you have the sound file in a sub folder 
>> in the bundle, simply make sure to include that in the path.
>> 
>> Chris Sheffield
>> 
>> 
>> On Jun 20, 2012, at 7:46 AM, Roger Guay <i...@mac.com> wrote:
>> 
>>> Hi all,
>>> 
>>> I'm trying to play a sound in iOS.
>>> 
>>> My code:                    if the environment is "mobile" then 
>>> mobilePlaySoundOnChannel  "mySnd.wav", "current", "now"
>>>                             else play "mySnd.wav"
>>> 
>>> I've imported mySnd.wav to the stack and I've copied it to the "Non-stack 
>>> files in the application" of the Standalone Application Settings.
>>> 
>>> it works in the IDE but not in the simulator nor my iPad. 
>>> 
>>> Any help please?
>>> 
>>> Thanks!
>>> Roger 
>> 
> 
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to