Monday, July 23, 2018

#1 2003-05-02 04:47:20 pm

Trash Man
Sanitation Department
Registered: 2005-10-20
Posts: 5336

How to return the name of a sound file?

I just figured out how to load sounds in Applescript Studio, but I'm having some problems:

First, I'd like to be able to display the name of the sound file that I've selected, but it doesn't seem to be easy to do. If I use the following code:

Applescript:

on clicked theObject
if name of theObject = "select_sound" then
       set the_sound to load sound (choose file with prompt "Pick a sound:")
       set contents of text field "sound_name" of window "window" to interval_sound
       play interval_sound
   end if
end clicked

Then it gives me some gibberish like {NS Sound # 23534} or something like that as the name of the sound. I tried some versions of "path to" ... "as string" but I couldn't seem to get it right. Any ideas?

Secondly, the URL above discusses the need to "free" sounds that have been loaded when changing sounds, but the example seems difficult and confusing. Anyone know a simple way that I could adjust the above code so that it would free any loaded sound (if there was one) before loading a new one?

Third, rather than having the user navigate to the system folder, then to the sounds folder, is there any way I could simply provide a list of sounds in the sounds folder for them to choose from?

Thanks!


One mans trash is another mans treasure

Offline

 

#2 2003-05-02 08:03:35 pm

Trash Man
Sanitation Department
Registered: 2005-10-20
Posts: 5336

Re: How to return the name of a sound file?

There is some information about working with sound names here but I don't really understand the documentation, and there are no usable examples that I can find. Anyone able to make sense of this?


One mans trash is another mans treasure

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)