Re: Can't make QuickTime Player 7 Pro auto quit on finishing playing a track
Re: Can't make QuickTime Player 7 Pro auto quit on finishing playing a track
- Subject: Re: Can't make QuickTime Player 7 Pro auto quit on finishing playing a track
- From: David Gregg <email@hidden>
- Date: Sat, 03 Jun 2017 16:54:48 -0600
Hi Ilja,
I attempted something similar with connecting various movie scenes, each in a separate QT7 file, and arranged into a light table, so that they would play in sequence. As you found, it didn't seem easy to decipher the QT7 dictionary, and what the various values meant. So, I went back to basics.
While not pretty, and processor intensive, I have found that a repeat loop with a test for the selection end of the movie/song works.
e.g.
tell application "QuickTime Player 7"
activate
open file wakeup_tune
tell document named song_name
set sound volume to EnteredVolume
play
set songEnd to false
repeat until songEnd
if current time ≥ selection end then set songEnd to true
end repeat
end tell
quit
end tell
> On Jun 3, 2017, at 1:40 PM, ILJA SHEBALIN <email@hidden> wrote:
>
> Hello again,
>
> Some time ago I wrote a script based on another example script in the book I'm learning AS from. The script wakes me up by playing a chosen track at a set time. A player app is QuickTime Player, but since I love QuickTime Player 7 Pro more I use the latter in the script for opening files to play. Everything's fine - it counts the time remaining until the time to wake me up and all that jazz, opens a file and plays it - except one thing: I want the app to quit it having finished to play the audio file (document or movie, as put in the app's Dictionary - both are interchangeable synonyms) but can't. When it finishes playing the file the app is still running and the frontmost window stays open. Here's a snippet of my script which is a pared down version (I omitted setting date and time lines of the code and other related stuff). See my comments for additional details. Remove the hash signs to make an appropriate line of your choice in the code below active). What can I do about that?
>
> The script:
>
> property wakeup_tune: missing value
> property song_name : missing value --not sure of its necessity
>
>
>
> repeat
> set wakeup_tune to choose file with prompt "CHOOSE AUDIO FILE" of type {"public.audio"} default location alias "(*any folder that you locate the audio file in*)"
> set wakeup_tune to wakeup_tune as text
> tell application "Finder" to set song_name to name of file wakeup_tune
>
> end repeat
>
>
> set VolumePrompt to display dialog "Enter volume value" & return & return & "Any integer between 0 (min) and 256 (max)" default answer "" --smth not very explicitly clear. In the dictionary values that "sound volume" can hold are described as follows: "sound volume (integer) : the sound volume of the movie (0..384), where 256 is 100%". if 256 is 100% then how 384 came up?
> set EnteredVolume to text returned of VolumePrompt as integer
>
>
>
> tell application id "com.apple.quicktimeplayer" --"QuickTime Player 7" makes no difference.
> activate
> open file wakeup_tune
> #set quit when done to true --shows error 1708 when placed here
> tell document named song_name
> set track_time to (get duration) --in the app's Dictionary the "duration" property is described as an integer value without specifying measurement units (sec, ms, what?) and returns incomprehensible values: in my case the duration of 1:08.06 (1 min 8 sec 6 ms) of a chosen file transformed into 46840. I don't know what that means. Too small for ms either since for that figure it should be 78060 ms so I'm mystified.
>
> set sound volume to EnteredVolume
> play
> #set quit when done to true --no effect
> #set close when done to true --takes effect by closing the frontmost window with the document been played but leaves the app running.
> end tell
> delay track_time --was meant to let the script make the document play before quitting the app. No need of this line when using "quit when done" property but (IMPORTANT!) in absence of the latter it's needed since "quit" command quits the app before the document been played and it's the only way of actually auto quitting the app (i.e. no "quitting when done" and "delay track_time" in the script: undesired).
> #set quit when done to true --shows error 1708 when placed here.
> #set auto quit when done to true --no effect
> #quit --no effect
> end tell
>
>
>
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> AppleScript-Users mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> Archives: http://lists.apple.com/archives/applescript-users
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden