Help with simple sound button

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
jessamy99
Posts: 103
Joined: Thu Oct 25, 2012 3:23 pm

Help with simple sound button

Post by jessamy99 » Sun Jun 15, 2014 9:22 pm

Dear Team,

You always manage to sort me out!!

I am at a complete loss!!
And I am sure I am doing something really silly here!!
I have read the forum and the dictionary and am still not succeeding!!
I just want a sound file to play when a button is pressed.

In the card I have this...

put getLoc("11sounds") & item 11 of tData into tAudioPath
put item 11 of tData into tSound
put tSound into tAudio

and in the button I have this...

on mouseUp
if the environment is mobile then
play audioClip (specialFolderPath ("cache") & "/theContent/11sounds/" & tAudio)
else
play audioClip "/Users/jessamy99/Desktop/soundApp/theContent/11sounds/" & tAudio
end if
end mouseUp

The correct audio clip plays on the mac, and in the simulator.
But it will not play on my iPhone 5 at all.

What am I doing wrong?

Thanking you all in advance for your hard work and help!

With best wishes,
Jessamy

PS Using Mac 10.9 Mountain Lion
LiveCode 6.1.2
iPhone 5 version 6.1.3

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Help with simple sound button

Post by Simon » Sun Jun 15, 2014 9:54 pm

Hi jessamy99,
AudioClip is not supported in mobile.
Just use "play".

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

jessamy99
Posts: 103
Joined: Thu Oct 25, 2012 3:23 pm

Re: Help with simple sound button

Post by jessamy99 » Mon Jun 16, 2014 1:54 pm

Dear Simon,

Thankyou so much! That was a really quick reply!!
And so simple!!

Now I have sound!
But only through the headphones!

Is there a way to make it come out of the speakers except when the headphones are plugged in?

The dictionary says to set it as external, but not on ios!!

This is the first time I have attempted to insert sound, so please bear with me if I am being daft!!

Many thanks for the help in advance and for the above!
It is much appreciated,

Best wishes,
Jessamy

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Help with simple sound button

Post by Simon » Mon Jun 16, 2014 8:21 pm

Sorry Jessamy,
The command is "play file" not just "play", look that up in the dictionary.
But in saying that it looks like your code should work with just play. Maybe you should try it the dictionary way and load the path into a variable and play that.

Now why it's headphones only is another matter entirely.

The hip way these days is to use "mobilePlaySoundOnChannel" pretty much the same as you are doing not much to learn but it may work better for you.
put specialFolderPath("engine") & "/sounds/applause.mp4" into tSoundFile
mobilePlaySoundOnChannel tSoundFile, "current", "now"
Don't worry about that "current" it can be any name you like.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

jessamy99
Posts: 103
Joined: Thu Oct 25, 2012 3:23 pm

Re: Help with simple sound button

Post by jessamy99 » Tue Jun 17, 2014 5:07 pm

Dear Simon,

Thankyou so much for all your help!

Actually the sound files are working perfectly and stoppng with a stop button.
However, while I have sound externally and internally on the old ipad, running 5.1.1,
on my iPhone 5 I only have intrnal sound.

That is fine as I shall put in the instructions that one needs headphones!! :)

I would like to know how to turn on the external sound for the future though!

Once again, your help is much appreciated!!
Best wishes,
Jessamy.

Klaus
Posts: 14182
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Help with simple sound button

Post by Klaus » Tue Jun 17, 2014 5:50 pm

Hi Jessamy,

I do not think that Livecode can control the internal/external output of an iPhone,
so I am sure the problem lies somewhere in your iPhone settings! 8)


Best

Klaus

jessamy99
Posts: 103
Joined: Thu Oct 25, 2012 3:23 pm

Re: Help with simple sound button

Post by jessamy99 » Tue Jun 17, 2014 8:02 pm

Dear Simon and Klaus,

It was me being totally daft!!
It was my settings!!

Thankyou for your patience and help!

It works now!! Very pleased!!

Best wishes,
Jessamy.

UPDATE

For anyone who is trying to get sounds, the script above worked perfectly on my iPhone and iPad, and on the Mac using aiff files.
But, for Android, I just needed to change the sound files to mp3 files at 128 bit rate.
I used audacity for both.

Hope it helps others!!

Best wishes,
jessamy.

trags3
Posts: 432
Joined: Wed Apr 09, 2014 1:58 am

Re: Help with simple sound button

Post by trags3 » Mon Jan 19, 2015 10:01 pm

jessamy99 wrote:Dear Team,

You always manage to sort me out!!

I am at a complete loss!!
And I am sure I am doing something really silly here!!
I have read the forum and the dictionary and am still not succeeding!!
I just want a sound file to play when a button is pressed.

In the card I have this...

put getLoc("11sounds") & item 11 of tData into tAudioPath
put item 11 of tData into tSound
put tSound into tAudio



and in the button I have this...

on mouseUp
if the environment is mobile then
play audioClip (specialFolderPath ("cache") & "/theContent/11sounds/" & tAudio)
else
play audioClip "/Users/jessamy99/Desktop/soundApp/theContent/11sounds/" & tAudio
end if
end mouseUp

The correct audio clip plays on the mac, and in the simulator.
But it will not play on my iPhone 5 at all.

What am I doing wrong?

Thanking you all in advance for your hard work and help!

With best wishes,
Jessamy

PS Using Mac 10.9 Mountain Lion
LiveCode 6.1.2
iPhone 5 version 6.1.3
Jessamy
I am starting an app that requires the same kind of sound playing that you did last year.
I just have a couple of questions.
what kind of storage are your audio files in?
are they separate files in a folder named "11sounds" ? If so are there 11 separate files?
Thanks for your help.
Tom

jessamy99
Posts: 103
Joined: Thu Oct 25, 2012 3:23 pm

Re: Help with simple sound button

Post by jessamy99 » Tue Jan 20, 2015 12:49 am

Dear Tom,

I have attached a zip file with a simple program that uses sound files for you.
You must copy the folder "sounds" to desktop.
Then, the program should run on a mac.
In the content folder are the sounds to run on an iPhone or iPad.
You will need to change the setting in application settings to your own profile first.

To run it on android you need to change the aiff files to mp3 files in both sound folders.

I hope this help.
Let me know.

All the best,
Jessamy
Attachments
music test 1.zip
(68.79 KiB) Downloaded 259 times

trags3
Posts: 432
Joined: Wed Apr 09, 2014 1:58 am

Re: Help with simple sound button

Post by trags3 » Tue Jan 20, 2015 1:36 am

Jessamy,
Thank You so much for the quick response. I will check this out. I'm sure it will help me understand what I am not doing correctly.

Tom

jessamy99
Posts: 103
Joined: Thu Oct 25, 2012 3:23 pm

Re: Help with simple sound button

Post by jessamy99 » Tue Jan 20, 2015 4:08 am

Dear Tom,

You are welcome!
This is a half built one!
But I hope you will follow it.

If not, get back to me and I will simplify it.

Bear in mind that I am a beginner!

All the best,
Jessamy

Post Reply