Search code examples
applescriptquicktime

AppleScript to launch and loop a video?


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

Solution

  • 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.