Scripting QuickTime to play video based on time of day

Hi guys,

This is a weird one :slight_smile:

I have a 12 hour long QuickTime video which is basically just a recording of a clock-face. I’d like to have a script that can open this video, make it full screen, check the system time and then set the video to play at the corresponding time and loop.

Here’s what I have cobbled together so far and I haven’t had very much luck with it. I’m still learning AppleScript and it’s a little difficult for me to piece together everything I read online. Any help would be so appreciated.

Thanks!

set desiredPosition to time of (current date)

tell application "QuickTime Player"
	set current time of document 1 to desiredPosition
	set looping of document 1 to true
	tell application "QuickTime Player" to play the front document
end tell

Hi,

try this


set desiredPosition to (time of (current date)) mod (12 * hours)

tell application "QuickTime Player"
	tell document 1
		set current time to desiredPosition
		set looping to true
		set presenting to true
		play
	end tell
end tell


Wow, amazing! Thank you so much.

Was just wondering if there was a way to make it call up the specific video file so I don’t need to have it open first…or have it be a droplet or something along those lines?

Thanks again!

just add an open line, the literal string must be the full path to the file, starting with a disk name
and colon separated


set desiredPosition to (time of (current date)) mod (12 * hours)

tell application "QuickTime Player"
	open file "Disk:path:to:clock.mov"
	set current time of document 1 to desiredPosition
	set looping of document 1 to true
	tell application "QuickTime Player" to play the front document
end tell


Thanks so much! I learned a lot!

Just out of curiosity can I get VLC to do the same thing? I tried this

set desiredPosition to (time of (current date)) mod (12 * hours)

tell application "VLC"
	open file "Macintosh HD:Users:Me:Desktop:clock.mov"
	tell document 1
		set time to desiredPosition
		set looping to true
		set fullscreen to true
		play
	end tell
end tell


but I keep getting the error “VLC got an error: Can’t set time of document 1 to 34084.” I looked up the definitions in the VLC applescript dictionary but I couldn’t find anything to do with “time” or “current time” or “playhead”.

Thanks again for all the help!