applescript mania

I wrote this little script today to help demonstrate the differences between media encoded at various bitrates using the AAC (mpeg4) codec, compared to straight uncompressed aiff and a 128Kbit mp3 for reference. Feel free to use this for your purposes. In order to function, the directories track1, track2, track3, and track4 would each contain the various versions of the track encoded in different bitrates. The script then opens up all the files for a specific track and plays them all at the same time). The user can then switch between windows and the audio source will follow along (just like the demo they did @ macworld). Oh yeah, this was designed to run on a machine withi a Cinema HD, so if you have too many different bitrates for each track, some of the windows will be placed off the bottom of your screen.

tell application "QuickTime Player"
	display dialog "This applescript will open multiple versions of the same tracks encoded at various bitrates using the new AAC codec.
To compare the tracks, click on the various windows while they are playing, and the audio source will change accordingly."
	display dialog "Which track would you like to compare? (enter a number 1 through 4)" default answer "1"
	set answer to the text returned of the result
	if answer is "1" then
		set the source_folder to ("Macintosh HD:Users:Shared:aac_test:track1") as alias
		set the item_list to list folder source_folder without invisibles
		set source_folder to source_folder as string
		set i to "1"
		repeat until i > (count of item_list)
			set open_me to item i of item_list
			set this_item to (source_folder & open_me) as alias
			open this_item
			set position of the front window to {3, ((100 * i))}
			set i to i + 1
		end repeat
		set i to "1"
		repeat until i > (count of item_list)
			play movie [i]
			set i to i + 1
		end repeat
	end if
	if answer is "2" then
		set the source_folder to ("Macintosh HD:Users:Shared:aac_test:track2") as alias
		set the item_list to list folder source_folder without invisibles
		set source_folder to source_folder as string
		set i to "1"
		repeat until i > (count of item_list)
			set open_me to item i of item_list
			set this_item to (source_folder & open_me) as alias
			open this_item
			set position of the front window to {3, ((100 * i))}
			set i to i + 1
		end repeat
		set i to "1"
		repeat until i > (count of item_list)
			play movie [i]
			set i to i + 1
		end repeat
	end if
	if answer is "3" then
		set the source_folder to ("Macintosh HD:Users:Shared:aac_test:track3") as alias
		set the item_list to list folder source_folder without invisibles
		set source_folder to source_folder as string
		set i to "1"
		repeat until i > (count of item_list)
			set open_me to item i of item_list
			set this_item to (source_folder & open_me) as alias
			open this_item
			set position of the front window to {3, ((100 * i))}
			set i to i + 1
		end repeat
		set i to "1"
		repeat until i > (count of item_list)
			play movie [i]
			set i to i + 1
		end repeat
	end if
	if answer is "4" then
		set the source_folder to ("Macintosh HD:Users:Shared:aac_test:track4") as alias
		set the item_list to list folder source_folder without invisibles
		set source_folder to source_folder as string
		set i to "1"
		repeat until i > (count of item_list)
			set open_me to item i of item_list
			set this_item to (source_folder & open_me) as alias
			open this_item
			set position of the front window to {3, ((100 * i))}
			set i to i + 1
		end repeat
		set i to "1"
		repeat until i > (count of item_list)
			play movie [i]
			set i to i + 1
		end repeat
	end if
end tell

About dre

I like all kinds of food.
This entry was posted in lj. Bookmark the permalink.

Leave a Reply