AppleScript to launch and loop a video?

8.7k views Asked by At

I need to write an AppleScript so that it will open QuickTime Player, play the movie from the specific file, and set it to loop in full screen. Help please I am a noob at writing AppleScripts.

This is what I have so far but it does not seem to work. :(

tell application "QuickTime Player"
   open file "Macintosh HDN:Users:lalayana:Downloads:TV Master Keynote.m4v"   
   set the looping of movie 1 to true
   play movie 1
end tell
3

There are 3 answers

0
Jerry Stratton On BEST ANSWER

The easiest way to do it is probably to assign the value returned by open file to a variable, and then tell that variable (that is, tell that movie) to do what it needs to do.

tell application "QuickTime Player"
    set theMovie to open file "Macintosh HDN:Users:lalayana:Downloads:TV Master Keynote.m4v"
    tell theMovie
        set the presenting to true
        set the looping to true
        play
    end tell

    --use this to see what properties can be modified
    --get the properties of theMovie
end tell

You can uncomment get the properties of theMovie to see what properties are available to modify.

If that doesn’t work for you, you’ll also need to specify exactly what you mean by “it does not seem to work”. That is, what error occurs, if an error occurs, or what happens differently than what you expect. I’ve verified that the above does work with a movie on my end.

0
Erik B On

This worked for me. I use it to play video art pieces at the museum I work at. It works.

tell application "QuickTime Player"
    activate
    open alias "Users:ebowen:Desktop:MOUND_1.32GB_h264.mov"
    play the front document
end tell
tell application "System Events" to tell process "QuickTime Player"
    set frontmost to true
    tell menu bar item 5 of menu bar 1
        click menu item "Enter Full Screen" of menu 1
        click menu item "Loop" of menu 1
    end tell
end tell
0
D McClane On

I just had this problem and the solution above did not work for my apple computer, so I modified the script to get it to work. I wanted to the script to launch on boot, which I accomplished by going to System Preferences -> Users -> Login Items.

tell application "QuickTime Player"
    set theMovie to open file "Users:danielmcclane:Downloads:startvideo.mov"
    tell theMovie
        set the looping of theMovie to true
        set the present of theMovie to true
        play
    end tell
end tell