I have a Perl-based audio player that runs on OS X, and I need to update how the audio files are played. I'd like to use AppleScript to control the QuickTime Player, because it will do what I need, but am running into a couple of problems.
First, I need the QuickTime player to launch in the background. The way my Applescript is working now, it's putting the player in the foreground, which then requires users to click back on my Perl app to keep going.
Second, I would like to have playing a new audio file reuse the existing QuickTime Player window, so that there's only one player going at any given time. So if a song is playing, and they choose to play another song, it stops the currently playing song in the window and loads up a new one in the same window.
Here's a fairly representative sample of the AppleScript that I'm working with. I'd love to know if there's a way to accomplish both of those goals.
set unixFile to "/Users/minter/mp3/ThomasDolby-SheBlindedMeWithScience.mp3" set macFile to POSIX file unixFile set fileRef to (macFile as alias) tell application "QuickTime Player" open fileRef play the front document end tell delay 3 tell application "QuickTime Player" stop the front document close the front document end tell
So when I run this AppleScript, it pops the QT player window up in front. If I run the script again, it creates a new window. Both of those are the problems I'm trying to solve.
Any help would be appreciated!