Hello everyone…
hope someone can help me with this issue. I had a script to control an QuickTime Player audio recording. But it stopped working in Big Sur
My script to start the audio recording still works…
tell application “QuickTime Player”
activate
set new_recording to (new audio recording)
– the name of document 1 becomes document “Audio Recording”
delay 2
tell new_recording
start
end tell
end tell
But since upgrading to Big Sur my script to pause the audio recording does not work…
tell application “QuickTime Player”
activate
try
tell document "Audio Recording"
pause
end tell
set nothingwentwrong to true
on error
set nothingwentwrong to false
end try
end tell
I can’t figure out why. I tried “pause Document 1”, but nothing works.
Kevin. I don’t have a microphone attached to my computer and, for that reason, can’t start an audio recording. However, I would suggest that you start a recording and run the following script in Script Editor. Either it should pause the recording or report an error, which would indicate the nature of the issue.
tell application "QuickTime Player" to tell document 1
pause
end tell
The dictionary is lying. The “pause” command does not work. Whether this is a bug from Apple or is it done on purpose, I don’t know.
In fact, the application requires the OPTION key to be pressed before attempting to pause. This is how it works:
tell application "QuickTime Player"
activate
set new_recording to (new audio recording)
tell new_recording to start
delay 5 -- WAIT RECORDING FOR 5 SECONDS
end tell
tell application "System Events"
key down option -- REQUIRED
tell application process "QuickTime Player" to tell window 1 to ¬
click UI element 3 -- "||" (PAUSE BUTTON) OF RECORDING WINDOW
key up option -- REQUIRED
end tell
tell application "QuickTime Player" to display dialog "AUDIO RECORDING IS PAUSED"
I have no clue whether there is a Big Sur issue and for me, scripting QT Player is certainly a hassle. This script uses screen recordings rather than movie or audio but they should work similarly and don’t have any dependencies.
It records for 4 seconds, pauses for 6, then records for 4 more. Note that there is some overhead in the process so you don’t get four full seconds.
set ft to ((path to desktop) & "crap.mov" as text) as «class furl»
-- file "Mac:Users:username:Desktop:crap.mov"
tell application "QuickTime Player"
activate
close windows without saving
set nsr to new screen recording
tell nsr
tell me to set nBeg to round (seconds of (current date)) + 2 rounding down
start
delay 4 -- record for 4 seconds less overhead
pause -- pause recording for 6 seconds then resume
delay 6
resume
delay 4 -- record for 4 seconds less overhead
stop
tell me to set nEnd to round (seconds of (current date)) - 1 rounding down
end tell
-- Export > 720p mov
tell me to close access (open for access ft with write permission)
set nrd to first document
export nrd in ft using settings preset "720p"
end tell
-- Imprecise opening and closing seconds
-- (Your clock should be set to 'display the time with seconds' or this has no point)
display notification "Captured seconds between " & nBeg & " to " & nEnd
On my system, recording duration is about 6.6 seconds and spans a period of about 12 seconds. It’s possible that if you set the delays to 4.7 seconds (4 + ((8-6.6)/2) then you might get 8 full seconds of recording (on my system the result was exactly 8000 ms :)) but that will likely throw off the notification’s timings. Delete the extraneous lines at your convenience.
tell application “System Events”
key down option – REQUIRED
tell application process “QuickTime Player” to tell window 1 to ¬
click UI element 3 – “||” (PAUSE BUTTON) OF RECORDING WINDOW
key up option – REQUIRED
end tell
on my system the Key Down option does not work. The script simple stops the recording, but does not pause it
Assuming the audio recording run already, you don’t need start recording from script, but “QuickTime Player” still should be on the front before its GUI scripting, because we want send commands to GUI of “QuickTime Player” and not to GUI of “Script Editor”:
tell application "QuickTime Player" to activate -- THAT: is required
tell application "System Events"
key down option -- REQUIRED
tell application process "QuickTime Player" to tell window 1 to ¬
click UI element 3 -- "||" (PAUSE BUTTON) OF RECORDING WINDOW
key up option -- REQUIRED
end tell