Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 6135 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Hello

I have a filemaker pro database I created for my wife to store her client information and notes in.

She also makes hypnosis tapes and would like to store the sound files in her database and burn them to CD

What I have done is used 24usoftware simplesound plugin to create .aiff files from within filemaker. I store the file in a folder in the documents folder. In the database I have one field the stores the filepath to the folder and one field that stores the name of the sound file.

The only way I can figure out to burn a CD is to use iTunes. I have figured out how to add the file to iTunes. I can't figure out how to tell iTunes to burn a CD, so I inserted a dialog command in the applescript to pause the script until the user has manually burned a CD. After the CD is burned the user clicks OK in the applescript dialog box and the script deletes the file and playlist it created.

This is not very elegant. It would be better if either I could applescript the whole thing or find a better way to pause Applescript while the user burns the CD. The script is as follows

tell application "FileMaker Pro"

set File_path to cell "file-path"

-- this cell stores the filepath to soundfolder

set this_file to File_path & ":" & cell "currentsound"

set playlist_name to cell "FullName"

end tell

tell application "iTunes"

activate

set my_playlist to make new playlist

set name of my_playlist to playlist_name

tell my_playlist

add this_file to my_playlist

end tell

set artist of track 1 of my_playlist to "Allyn Miller,MFT"

set album of track 1 of my_playlist to "Meditation by Allyn Miller, MFT"

set genre of track 1 of my_playlist to "Meditation"

end tell

activate

display dialog "click on playlist then the burn button. Click on OK when you have ejected the CD"

tell application "iTunes"

activate

delete my_playlist

delete (tracks of library playlist 1 whose artist is "Allyn Miller,MFT")

end tell

thanks for any help :

Posted

There's probably a way to just burn a folder of audio files to CD directly. But being a dull kind of guy, who's supposed to be finishing a database instead of playing with music, I can only tell you a snippet of what I found at Doug Adams' iTunes AppleScripts site.

It uses System Events to click the menu item for you. Otherwise much the same.

set pList to "your playlist here"

tell application "iTunes"

try

set view of front browser window to playlist pList

tell application "System Events"

tell process "iTunes"

click the menu item "Burn Playlist to Disc" of the menu "File" of menu bar 1

end tell

end tell

end try

end tell

Posted

thanks I will try that, but...

Since I want to delete the playlist and track after I burn the CD how do I tell applescript to wait for the burn process to finish before running the rest of the script and deleting the track

Kevin

Posted

you're right I just assumed it wouldn't. I will try it and let you know

Posted

Well, I tried what you said. If I left the script at the click menu step iTunes waited for a disc to burn.

Adding the delete steps after the script just went ahead and deleted the track and playlist without waiting for the Burn Disc step

Here is the script I tried:

set this_file to "MacBook HD:Users:Kevin:Documents:allyn database stuff:savedaudio:kevin.aif"

tell application "iTunes"

activate

set my_playlist to make new playlist

set name of my_playlist to "AllynClientName"

tell my_playlist

add this_file to my_playlist

end tell

set artist of track 1 of my_playlist to "Allyn Miller,MFT"

set album of track 1 of my_playlist to "Meditation by Allyn Miller, MFT"

set genre of track 1 of my_playlist to "Meditation"

try

set view of front browser window to my_playlist

tell application "System Events"

tell process "iTunes"

click the menu item "Burn Playlist to Disc" of the menu "File" of menu bar 1

end tell

end tell

end try

delete my_playlist

delete (tracks of library playlist 1 whose artist is "Allyn Miller,MFT")

end tell

  • 4 weeks later...
Posted

I have finally finished the script. I use "simplesound" plug in from 24u software to create the .AIFF sound file. A reference to it is stored in Filemaker Pro. The script looks for the parameters on a preferences layout in Filemaker Pro and sends feedback to the same Preferences layout. I know it is not the most elegant script, so if anyone has suggestions to improve the script please let me know.

Kevin

(*

this script is adapted from

"Whack Current Track" for iTunes

written by Doug Adams

[email protected]

Also from Applescript by Hanaan Rosenthal, and help and suggestions from www.macscripter.net, and www.fmforums.com

Kevin Miller

*)

-- Taken from a preferences layout in Filemaker that contains parameters I want to pass to this applescript

tell application "FileMaker Pro"

set this_file to cell "_cMyFolder_AS" & "savedaudio:" & cell "ToBurnSound"

set pList to cell "Filteredalbumname"

set partist to cell "Filteredartistname"

set pyear to cell "YearOfVoicenote" as number

-- gwarn is a setting in Filemaker Pro database to know how much feedback the user wants

set gwarn to cell "gwarned" as number

end tell

--Test this_file to see if it exists

tell application "Finder"

-- returns true or false

set file_exists to (exists file this_file)

end tell

if (file_exists) then

--test to see if file is an AIFF sound file

tell application "System Events"

set what_kind_of_file to (kind of (info for file this_file))

end tell

if what_kind_of_file is "AIFF Audio File" then

-- add audio file referenced in Filemaker Pro to iTunes

set new_track to my add_sound_to_iTunes(pList, pyear, this_file, partist, gwarn)

-- tell iTunes to burn the CD

set {addenda, user_cancel} to (my Burn_the_CD(pList))

-- notify user of status of Burn CD routine

activate me

if gwarn = 1 then

display dialog addenda buttons {"I understand"} default button 1 with icon 1 giving up after 10

else

display dialog addenda buttons {"I understand"} default button 1 with icon 1

end if

--Pass result of Burn_the_CD routine to Filemaker pro so it be used later in a Filemaker script

tell application "FileMaker Pro"

set cell "ToBurnSound" to user_cancel

end tell

--delete iTunes track that we added from Filemaker Pro

set addenda to my remove_track_from_iTunes(new_track, pList)

--notify user of status of iTunes delete routine

activate me

if gwarn = 1 and addenda does not contain "track could not be deleted" then

display dialog addenda buttons {"I understand"} default button 1 with icon 1 giving up after 10

else

display dialog addenda buttons {"I understand"} default button 1 with icon 1

end if

else

set addenda to "The sound file is not the correct type to burn. Contact tech support or record a new voice note and try to burn a CD again."

set user_cancel to "wrong file type"

my alert_user_and_cancel(addenda, user_cancel, gwarn)

end if

else

set addenda to "The sound file is corrupted or could not be found on your computer. Contact tech support or record a new voice note and try to burn a CD again."

set user_cancel to "no file found"

my alert_user_and_cancel(addenda, user_cancel, gwarn)

end if

on add_sound_to_iTunes(pList, pyear, this_file, partist, gwarn)

tell application "iTunes"

activate

make new playlist with properties {name:pList}

set new_track to (add this_file as alias)

--allow time to import track or you might get a file permissions error

delay 2

set dbid to database ID of new_track

set this_track to some track of library playlist 1 whose database ID is dbid

duplicate this_track to playlist pList

set artist of new_track to partist

set album of new_track to pList

set genre of new_track to "Meditation"

set year of new_track to pyear

return new_track

end tell

end add_sound_to_iTunes

on Burn_the_CD(pList)

-- still not good way to determine if the user has quit iTunes manually

activate me

display dialog "Do not use this computer while iTunes is Burning the CD." & return & return & " Follow the instructions in the iTunes window to insert a Blank CD. Do not quit iTunes; this program will do that for you." buttons {"I understand"} default button 1 with icon 1 giving up after 10

tell application "iTunes"

activate

try

set view of front browser window to user playlist pList

tell application "System Events"

tell process "iTunes"

click the menu item "Burn Playlist to Disc" of the menu "File" of menu bar 1

end tell

end tell

-- set m to be a counter to give up after 10 minutes

set m to 0

repeat until m = 600

if (kind of container of view of front browser window is audio CD) then

delay 2

tell application "System Events"

tell process "iTunes"

click the menu item "Eject Disc" of the menu "Controls" of menu bar 1

end tell

end tell

set addenda to "Disc burn successful. I will now delete the track from iTunes and return to your database. The voice note in your database has not been touched."

set user_cancel to "CD Burn successful"

return {addenda, user_cancel}

exit repeat

else

delay 1

set m to (m + 1)

end if

end repeat

if m = 600 then

set addenda to "Your CD was not burned because iTunes stopped responding. I will now delete the track from iTunes and return your database. The voice note in your database has not been touched."

set user_cancel to "iTunes timed out"

return {addenda, user_cancel}

end if

on error number the_error

set addenda to "Your CD was not burned because of an unexpected error. I will now delete the track from iTunes and return to your database. The voice note in your database has not been touched."

set user_cancel to "CD Burn error"

return {addenda, user_cancel}

end try

end tell

end Burn_the_CD

on remove_track_from_iTunes(new_track, pList)

tell application "iTunes"

activate

set track_name to name of new_track

set ofi to fixed indexing

set fixed indexing to true

try

set dbid to database ID of new_track

set cla to class of new_track

set floc to (get location of new_track)

delete (some track of library playlist 1 whose database ID is dbid)

set addenda to "Done. The track has been deleted from iTunes."

delete user playlist pList

if cla is file track then

set addenda to "Done. The track has been deleted from iTunes and its file has been moved to the Trash."

set file_deleted to my delete_the_file(floc)

if file_deleted = "error" then

set addenda to "Done. However, the file in iTunes could not be moved to the Trash."

end if

end if

on error

set addenda to "The track could not be deleted from iTunes. Please open iTunes manually and delete the Playlist " & pList & ". Also delete from the library track " & track_name & ". Please tell tech support this happened."

set fixed indexing to ofi

return addenda

end try

set fixed indexing to ofi

quit

return addenda

end tell

end remove_track_from_iTunes

to delete_the_file(floc)

try

-- tell application "Finder" to delete floc

do shell script "mv " & quoted form of POSIX path of (floc as string) & " " & quoted form of POSIX path of (path to trash as string)

return "OK"

on error

return "error"

end try

end delete_the_file

to alert_user_and_cancel(message, user_cancel, gwarn)

if gwarn = 1 then

display dialog message buttons {"I understand"} default button 1 with icon 0 giving up after 20

else

display dialog message buttons {"I understand"} default button 1 with icon 0

end if

tell application "FileMaker Pro"

activate

set cell "ToBurnSound" to user_cancel

end tell

end alert_user_and_cancel

This topic is 6135 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.