Muting a grid of streaming videos in QuickTime Player windows

Hi everybody,

I am learning AppleScript and this forum is a treasure trove. Thanks so much!
My first project is this, I’m opening four video streams in QuickTime Player and placing the windows in a 2x2 grid. This is the relevant AppleScript, it works great:

tell application "QuickTime Player" to open URL channel1
tell application "QuickTime Player"
	set bounds of front window to {0, 23, 720, 460}
	
end tell


tell application "QuickTime Player" to open URL channel2
tell application "QuickTime Player"
	set bounds of front window to {720, 23, 1440, 460}
	
end tell

tell application "QuickTime Player" to open URL channel3
tell application "QuickTime Player"
	set bounds of front window to {0, 460, 720, 900}
	
end tell

tell application "QuickTime Player" to open URL channel4
tell application "QuickTime Player"
	set bounds of front window to {720, 460, 1440, 900}
	
end tell

What I am stumped on is the AUDIO MUTING part. Ideally I would like 3 of the 4 windows to be muted so only the audio of one window is heard.

I tried invoking the “OPTION-DOWN ARROW” keyboard shortcut, which works when pressed manually inside QuickTime Player. But it doesn’t work via this AppleScript, or with many other variations I tried.

tell application "System Events" to tell process "QuickTime Player"
	
	repeat with w in (get every window)
		tell window "QuickTime Player"
			key code 125 using option down
		end tell
	end repeat
	
end tell

I also tried some variations of

  set audio volume to "0"

which I thought would be a cleaner way of getting there.
But I couldn’t get that working, either.

I’m sure I’m missing something basic, but I’m new to this and still learning. So thanks for any help you can provide.

Try:

tell application "System Events" to tell process "QuickTime Player"
	set frontmost to true -- ADDED
	repeat with w in (get every window)
		tell window "QuickTime Player"
			key code 125 using option down
		end tell
	end repeat
	
end tell

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mardi 11 aout 2020 18:14:13

Thank you! That helped a bit, it actually muted the 4th of my four open QT Player windows. Which is great progress, I’ve never gotten it to do even that. It also means I’m 1/3 of the way there!

Any help in getting windows 2 and 3 to mute as well would be very much appreciated :slight_smile:

SOLVED.

I got it working with this:

tell application "QuickTime Player"
    activate
    set every document's audio volume to 0
end tell