Hi Sideman,
02Sideman wrote:Good morning to you Klaus - Hopefully the GOOD side!
Hehe, very good
I am also a musician and play the bass, the world is avillage!
If you like to take a look/hear:
http://www.major-k.de/bass
OK, setting the filename of a player is as simple as it sounds:
Code: Select all
...
set the filename fo player "xyz" to "path/to/your/soundfile.aif"
...
So I would suggest the following:
Do only use one player ("main_player" in my example script) and set the filename with the different buttons.
I use these names for the buttons (a clever naming convention can save a lot of time and typing!)
Button to play clip 1 = "play_1"
Button to play clip 2 = "play_2"
Button to play clip 3 = "play_3"
The only difference in the scripts of these buttons are the filenames of your sounds:
Button "play_1":
Code: Select all
on mouseup
lock screen
## So the user will not see our tricks ;-)
## We simply reset all buttons to "Start"!
repeat with i = 1 to 3
set the label of btn ("play_" & i) to "Start"
end repeat
## First check if sound is playing
if the label of me = "Stop" then
## Stop and "reset" player object
stop player "main_player"
set the filename of player "main_player" to empty
set the currenttime of player "main_player" to 0
## Label was "Start"
else
set the label of me to "Stop"
## Now set the filename, this is the only differnce in the three buttons
set the filename of player "main_player" to "your filename here..."
start player "main_player"
end if
end mouseup
As you can see, with the clever naming convention NO button name or number needs to be in the script and so this script will work for any number of buttons!
Hope that helps!
Best from germany
Klaus