with timeout of 600 seconds
try
set the sound_folder to (path to library folder from user domain as
- Ignored:
text) & "Screen Saver Sounds" as alias
on error err_msg number err_num
if err_num is -43 then
do shell script "mkdir ~/Library/Screen\\ Saver\\ Sounds"
do shell script "ln -s /Library/Audio/Apple\\ Loops/Apple/iLife\\
Sound\\ Effects/Jingles ~/Library/Screen\\ Saver\\ Sounds/Jingles"
do shell script "open ~/Library/Screen\\ Saver\\ Sounds"
set ignored_result to display alert "A \"Screen Saver Sounds\"
folder has been created in the Library folder of your home directory."
message "Fill it with sound files movie files, folders of sound or
movie files, or aliases to these, and Screen Saver with Music will
play one every time it is launched."
set the sound_folder to (path to library folder from user domain as
text) & "Screen Saver Sounds" as alias
else
beep
say "Error number " & err_num & ": " & err_msg
end if
end try
try
tell application "Finder"
set enchilada to entire contents of the sound_folder
set no_items to count the items of enchilada
set i to random number from 1 to no_items with seed the time of
(current date)
set the choice to item i of the enchilada
repeat
if the class of the choice is alias file then
set the choice to the original item of the choice
else if the class of the choice is folder then
set the choice to some item of the choice
else
exit repeat
end if
end repeat
end tell
tell application "ScreenSaverEngine"
launch
end tell
tell application "Finder"
(* get the properties of the choice*)
set choice_extension to the name extension of the choice
open the choice using (path to application "QuickTime Player")
end tell
tell application "QuickTime Player"
set quit when done of the front document to true
if the choice_extension is in {"mov", "flv", "m4v"} then
activate
present front document
else
play front document
end if
end tell
on error err_msg number err_num
beep
say "Error number " & err_num & ": " & err_msg
end try
end timeout
-----
Aaron Solomon Adelman, PhD
Epidemiologist/statistician/computer expert