>Can you give an example that shows this?

You mean of the code? Here it is, sorry about the length (it'd need changes to
the hard file names to work elsewhere.) You need the freeware program Play Sound
at http://microcosmsoftware.com/playsound/. I have a version with a longer AS
that just talks to QuickTime, but it gets the same errors (also included.)
~wren

#!perl -w

$PlayAiff_AppleScript = <<END_SCRIPT; ### the short script using Play Sound
property my_current_directory : "Ezekiel:School-Thesis recordings:MYGROUPNAME:"
set soundFile to (my_current_directory & "MYFILENAME") as alias

ignoring application responses
        tell application "Fuchikoma:Applications:[ AV Utilities]:Play
Sound("X"1.0.6):Play Sound"
                play (soundFile as alias)
                quit
        end tell
end ignoring
END_SCRIPT

$Alt_PlayAiff_AppleScript = <<END_SCRIPT; ### the long script using QT
property my_current_directory : "Ezekiel:School-Thesis recordings:MYGROUPNAME:"
property this_item : a reference to alias (my_current_directory & "MYFILENAME")

on run
        -- NOTE that the variable this_item is a file reference in alias format
        -- FILE PROCESSING STATEMENTS GOES HERE
        try
                tell application "Fuchikoma:Applications:QuickTime Player X6.1"
                        launch -- bypasses promo movie
                        activate
                        my toggle_suppress(true)
                        
                        stop every movie
                        close every movie
                        
                        open this_item
                        set position of window 1 to {2, 20}
                        play movie 1
                        try
                                repeat
                                        if done of movie 1 is true then
                                                exit repeat
                                        else
                                                delay 3
                                        end if
                                end repeat
                                close movie 1
                        end try
                end tell
                my toggle_suppress(false)
                return true
        on error error_msg number error_num
                my toggle_suppress(false)
                if error_num is not -128 then
                        activate
                        display dialog error_msg buttons {"OK"} default button 1
                end if
                error number -128
        end try
end run

on toggle_suppress(status_flag)
        tell application "QuickTime Player X6.1"
                set ignore auto play to the status_flag
                set ignore auto present to the status_flag
        end tell
end toggle_suppress
END_SCRIPT

##### begin the actual perl

$group = 'A';
&PlayAiff('e-1a2.aiff');

sub PlayAiff {
        my $filename = shift; # get passed filename
        my $PlayAiff = $PlayAiff_AppleScript; # make local version of script
                                                                                       
                 # interpolate file & folder names for local script only
        $PlayAiff =~ s/MYGROUPNAME/Group A/g if ($group eq 'A');
        $PlayAiff =~ s/MYGROUPNAME/Group B/g if ($group eq 'B');
        $PlayAiff =~ s/MYFILENAME/$filename/g;
        MacPerl::DoAppleScript("$PlayAiff") or die ("Couldn't run script: $!\n", @$);
}
__END__

Reply via email to