Page 1 of 1

Help with simple sound button

Posted: Sun Jun 15, 2014 9:22 pm
by jessamy99
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

Re: Help with simple sound button

Posted: Sun Jun 15, 2014 9:54 pm
by Simon
Hi jessamy99,
AudioClip is not supported in mobile.
Just use "play".

Simon

Re: Help with simple sound button

Posted: Mon Jun 16, 2014 1:54 pm
by jessamy99
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

Re: Help with simple sound button

Posted: Mon Jun 16, 2014 8:21 pm
by Simon
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

Re: Help with simple sound button

Posted: Tue Jun 17, 2014 5:07 pm
by jessamy99
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.

Re: Help with simple sound button

Posted: Tue Jun 17, 2014 5:50 pm
by Klaus
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

Re: Help with simple sound button

Posted: Tue Jun 17, 2014 8:02 pm
by jessamy99
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.

Re: Help with simple sound button

Posted: Mon Jan 19, 2015 10:01 pm
by trags3
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

Re: Help with simple sound button

Posted: Tue Jan 20, 2015 12:49 am
by jessamy99
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

Re: Help with simple sound button

Posted: Tue Jan 20, 2015 1:36 am
by trags3
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

Re: Help with simple sound button

Posted: Tue Jan 20, 2015 4:08 am
by jessamy99
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