Inserting sounds Programmatically
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Inserting sounds Programmatically
Hi,
I want the user to click on a button, browse his/her files and select a specific sound file (WAV file). Then, I want to store the binary data of that sound in a variable (something similar to imageData for images).
How can I do that?
Thanks,
Haitham
I want the user to click on a button, browse his/her files and select a specific sound file (WAV file). Then, I want to store the binary data of that sound in a variable (something similar to imageData for images).
How can I do that?
Thanks,
Haitham
Dear Haitham,
This is easy.
Why do you want to do this?
Best,
Mark
This is easy.
Code: Select all
answer file "Select a sound file"
if it is not empty then
put url ("binfile:" & it) into myData
-- do with myData whatever you like here
end if
Best,
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
First, I have to thank you for your help.
Regarding you question, why do I want to do this.
Well, this might need some explanation. In short, the sound will be stored in a database file (SQLite file) in a binary format so that it can be played later directly from ANOTHER application.
Thus, I will ask another question.
Can I use quick time player, or any other things, to play the sound (which is already stored in a binary format)?
If there is no direct way, can I for example create a temp. file on the hard-drive, play it, then delete it?
Hope my question is clear.
Thanks,
Haitham
Regarding you question, why do I want to do this.
Well, this might need some explanation. In short, the sound will be stored in a database file (SQLite file) in a binary format so that it can be played later directly from ANOTHER application.
Thus, I will ask another question.
Can I use quick time player, or any other things, to play the sound (which is already stored in a binary format)?
If there is no direct way, can I for example create a temp. file on the hard-drive, play it, then delete it?
Hope my question is clear.
Thanks,
Haitham
Hi Haitham,
You can't set the sound data of a player object directly. You must have a file first and then set the filename of the player object. Some formats, such as wav and aiff, can be imported into your stack and the data of a video or audio clip can be written to a variable or file directly.
This works with clips only, not with players.
Best,
Mark
You can't set the sound data of a player object directly. You must have a file first and then set the filename of the player object. Some formats, such as wav and aiff, can be imported into your stack and the data of a video or audio clip can be written to a variable or file directly.
Code: Select all
put the text of audioClip 1 into myVar
put myVar into url "binfile:~/desktop/test.wav"
Best,
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
Load audio into player from another button
Is there a way to load an audio clip into a player from another button?
Thanks
Bidge
Thanks
Bidge
Bidge,
a player and an audioclip are different beasts.
An audioclip you load into the stack and then you play an audioclip (only wav, aiff, au) Useful for short clips that you want to stay in your stack.
a player plays a file on the hardisk. All the formats Quicktime supports.
You load a player with
you can put this into a button of course. Either you take the path from a list of pathes you generated before, or you let the user choose the file.
regards
Bernd
a player and an audioclip are different beasts.
An audioclip you load into the stack and then you play an audioclip (only wav, aiff, au) Useful for short clips that you want to stay in your stack.
a player plays a file on the hardisk. All the formats Quicktime supports.
You load a player with
Code: Select all
set the filename of player "xyz" to "/the/Path/to/my/file/myAudio.mp3"
regards
Bernd
Thanks once again Bernd.
I have been trying for hours to figure out how to get a button to load an mp3 into a player and start it. None of these work.
on mouseUp
load "purge.mp3" into player "Player"
--load audioClip "C:\purge.mp3"
--load "purge.mp3"into player"Player"
start player "Player"
end mouseUp
Cheers
Bidge
I have been trying for hours to figure out how to get a button to load an mp3 into a player and start it. None of these work.
on mouseUp
load "purge.mp3" into player "Player"
--load audioClip "C:\purge.mp3"
--load "purge.mp3"into player"Player"
start player "Player"
end mouseUp

Cheers
Bidge