0

I have 3 open VLC windows and whenever I see movement in one I need to pause all of them at once. Ideally I'd like a keyboard shortcut to do this. I tried AppleScript but I'm not familiar with the language and I can't see how to iterate through all processes of an application and tell each one individually.

  • If all three are actually playing something, how is it that you have more then one VLC window playing something? I seem to only be able to play one object at a time. – user3439894 Jun 7 '15 at 14:32
  • This is useful: open VLC.app with Script Editor and check out the VLC suite to see all the commands and properties it has. It turns out we can use the play command to toggle playing, like this: tell application "VLC" to play (but it won't solve the situation). – user128544 Jun 7 '15 at 14:57
  • 1
    @user3439894 there are several ways to get multiple windows showing, e.g. wiki.videolan.org/How_to_play_multiple_instances_of_VLC (the essential point there being open -n in the Terminal). – Alex Hall Jun 7 '15 at 15:11
  • BTW: on this site it states: "On the Mac, running multiple instances of VLC is not supported out of the box." - but that is wrong since we can just use the VLC executable (which is "/Applications/VLC.app/Contents/MacOS/VLC"). – user128544 Jun 7 '15 at 15:24
  • Well, it's supported by the OS, just not the VLC devs. I'll post a solution for this below – William T Froggard Jun 7 '15 at 15:29
0

This will check for all instances of VLC and pause any of the instances that are currently playing something. Let me know if something unexpected happens! To create the shortcut, follow these steps:

  1. Open Automator and create an Service, with a single Run AppleScript action, containing the following code:

    tell application "System Events" to repeat with VLC_instance in (application processes whose name is "VLC")
        tell the menu "Playback" of the first menu bar of VLC_instance
            if the menu item "Pause" exists then
                click menu item "Pause"
            else if the menu item "Play" exists then
                click menu item "Play"
            end if
        end tell
    end repeat
    
  2. Set the service to receive "no input" and to work in "VLC" or "any application", if you want to ensure you can use the shortcut from anywhere. Save it with a name of your choosing.

  3. Now, go into the Shortcuts tab in the Keyboard preferences in System Preferences, and click on Services. The newly created service should be at the bottom, under the name you chose. Click on the service, then click on "add shortcut", and specify a shortcut to your liking.
  4. You may have to allow Automator access in Accessibility in the Privacy tab of the Security and Privacy preferences.

That's it! You should now have a service set up, tied to the shortcut you chose that can be accessed from anywhere.

  • Just a thought: this will probably fail when "Video=>Window decorations" is disabled (=no buttons) but the "Playback" menu should always work (I think). – user128544 Jun 7 '15 at 16:26
  • That depends on whether or not the button is actually removed from the UI element hierarchy when that occurs (as it probably should be...). Your solution is probably safer though. – William T Froggard Jun 7 '15 at 17:22
  • 1
    There we go! Now it should be fairly robust. Thanks for the suggestion. :) – William T Froggard Jun 7 '15 at 17:30
  • hah, rewrote it in almost pure English just for the heck of it. I love AppleScript syntax. rofl... – William T Froggard Jun 7 '15 at 17:34
  • Thank you so much, this worked perfectly. I'd also like to be able to play the videos simultaneously again (probably should have mentioned that originally, edited the question for searchers). Since it'd be easier to have one shortcut for both I added an else clause: tell the menu item "Pause" of the menu "Playback" of the first menu bar of VLC_instance to if it exists then click it else tell the menu item "Play" of the menu "Playback" of the first menu bar of VLC_instance to click it end if. I'm guessing there's a better way? – Alex Hall Jun 7 '15 at 20:32
-2

When you have one VLC "active" (in front of you) hit CMD+Q and it is ended. And so with the next active one.

  • That would quit it, not pause, and the OP wants to pause all of them with one command. – Ruskes Jun 7 '15 at 18:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .