Selecting and playing a sound file in iOS?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Selecting and playing a sound file in iOS?
I can use the iTunes file sharing facility to copy mp3 files into the Documents folder of my app, and display them in a scrolling list field (on the iPad, not the simulator). And I can select one of them but I'm puzzled on how to play the selected file. There does not seem to be any explanation on how to do this in the manual or in any of the other places I have looked.
Could some kind person please point me in the right direction?
TIA
Could some kind person please point me in the right direction?
TIA
Re: Selecting and playing a sound file in iOS?
Hi Tia,
Does
work? You can retrieve the path with e.g.
Kind regards,
Mark
Does
Code: Select all
play "path/to/file.mp3"
Code: Select all
set the itemDel to slash
put (item 1 to -2 of the effective filename of this stack & "/file.mp3") into myPath
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
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Re: Selecting and playing a sound file in iOS?
Hi grovecat,
you can access the DOCUMENTS folder on iOS via:
specialfolderpath("documents")
And the currently selected text in a list field via:
the selectedtext of me ## if the script is in the field or
the selectedtext of fld "xyz"
Then you can combine both of them:
...
put specialfolderpath("documents") & "/" & the selectedtext of fld "xyz" into tSoundFile
## Now you have the EXACT path to the sound file and you can simply PLAY it:
play tSoundFile
...
You did not find this in the manual since this is just one of the gazillion options to create a path!
Please do also check the "iOS Release Notes" -> Menu: Help! for other available iOS "specialfolderpath"s and more info.
And do it with each new release!
To learn more about LiveCode check these stacks:
http://www.runrev.com/developers/lesson ... nferences/
Best
Klaus
you can access the DOCUMENTS folder on iOS via:
specialfolderpath("documents")
And the currently selected text in a list field via:
the selectedtext of me ## if the script is in the field or
the selectedtext of fld "xyz"
Then you can combine both of them:
...
put specialfolderpath("documents") & "/" & the selectedtext of fld "xyz" into tSoundFile
## Now you have the EXACT path to the sound file and you can simply PLAY it:
play tSoundFile
...
You did not find this in the manual since this is just one of the gazillion options to create a path!
Please do also check the "iOS Release Notes" -> Menu: Help! for other available iOS "specialfolderpath"s and more info.
And do it with each new release!
To learn more about LiveCode check these stacks:
http://www.runrev.com/developers/lesson ... nferences/
Best
Klaus
Re: Selecting and playing a sound file in iOS?
Hi Klaus,
It is possible to include files in the same folder as the stack (or executable file). This folder isn't always the documents folder. Also, the documents folder is a writable folder and you might feel slightly more comfortable keeping files in a non-writable folder. Moreover, including a documents folder with the stack didn't always work for me (but I haven't figures out whether it is me or LiveCode).
Kind regards,
Mark
It is possible to include files in the same folder as the stack (or executable file). This folder isn't always the documents folder. Also, the documents folder is a writable folder and you might feel slightly more comfortable keeping files in a non-writable folder. Moreover, including a documents folder with the stack didn't always work for me (but I haven't figures out whether it is me or LiveCode).
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
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Re: Selecting and playing a sound file in iOS?
Hi Mark,
whatever, I only tried to answer grovecats exact question:
How to play a sound which ALREADY resides in the documents folder of his app from its name listed in a list field.
Best
Klaus
whatever, I only tried to answer grovecats exact question:
How to play a sound which ALREADY resides in the documents folder of his app from its name listed in a list field.

Best
Klaus
Re: Selecting and playing a sound file in iOS?
You're right. I overlooked that.
Mark
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
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Re: Selecting and playing a sound file in iOS?
Thanks Klaus
That is exactly what I needed.
Don
That is exactly what I needed.
Don
Re: Selecting and playing a sound file in iOS?
Hi Don,
I know
Best
Klaus
I know

Best
Klaus