I’m struggling to make a one applescript that managing multiple audio files with volume controls.
When something happens I want to
play audio1
set audio2 and audio3 volume to 0
I’m using something like this, which is not working
tell application “QuickTime Player”
open audio1
ignoring application responses
play document 1
set audio volume of document 1 to “1”
set the looping of document 1 to true
end ignoring
stop document 2
set audio volume of document 2 to “01”
end tell
tell application "QuickTime Player"
open audio1
ignoring application responses
play document 1
set audio volume of document 1 to "1"
set the looping of document 1 to true
end ignoring
end tell
tell application "QuickTime Player"
ignoring application responses
stop document 2
set audio volume of document 2 to "01"
end ignoring
end tell
or
tell application "QuickTime Player"
open audio1
ignoring application responses
play document 1
set audio volume of document 1 to "1"
set the looping of document 1 to true
# The two instructions below MUST be in a tell application "QuickTime Player" block
stop document 2
set audio volume of document 2 to "01"
end ignoring
end tell
I’m wondering why you use “1” once and “01” an other time to set the audio volume.
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) samedi 21 décembre 2019 15:42:22
First I start an audio, and after 5 seconds I want to close it and play a new one.
But looks like Quicktime doesn’t like a “document 2” call, as it opens but does not start playing.
It plays if I call it “document 1”, again. but then I’m not sure how to control them if both are “document 1”! _
oh, never mind… I just realised that I have to open all the files at the beginning, so I will be able to process all of them by name, first opened one is document 1, second is document 2 etc.
Very beginner in applescripting quicktime!
set LaunchingFile to "/Users/Documents/System-Sounds/Quicktime/Launching.mp3"
set ReadyFile to "/Users/Documents/System-Sounds/Quicktime/Ready.mp3"
set thePaths to {LaunchingFile, ReadyFile}
repeat with aPath in thePaths
my playPath(aPath)
delay 5
end repeat
on playPath(aPath)
set aFile to POSIX file aPath
tell application "QuickTime Player"
if exists document 1 then stop document 1
open aFile
ignoring application responses
tell document 1
play
set audio volume to "1"
set looping to true
stop document 1
end tell
end ignoring
end tell
end playPath
or with :
script 2, load the files in a single task then it play the files one by one
set LaunchingFile to "/Users/Documents/System-Sounds/Quicktime/Launching.mp3"
set ReadyFile to "/Users/Documents/System-Sounds/Quicktime/Ready.mp3"
set thePaths to {LaunchingFile, ReadyFile}
set theDocuments to {}
repeat with aPath in thePaths
set aFile to POSIX file aPath
tell application "QuickTime Player"
set end of theDocuments to open aFile
end tell
end repeat
repeat with i from 1 to count theDocuments
tell application "QuickTime Player"
if i > 1 then stop item (i - 1) of theDocuments
ignoring application responses
tell item i of theDocuments
play
set audio volume to "1"
set looping to true
end tell
end ignoring
end tell
delay 5
end repeat
In both cases you may pass more than two paths.
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) samedi 21 décembre 2019 17:56:24