Get file path of movie playing in VLC

bashvlc

If VLC is running, playing a movie at file path X, is there any way I can know what file path X is from a Bash script? (For simplicity's sake we can assume that only one instance of VLC is running.)

Update: I now know this can be done using the following methods. Are there other ways, perhaps a way of asking VLC directly?

  1. AppleScript (macOS only)
  2. lsof (All Unix)

Best Answer

That's an easy one

osascript -e 'tell application "VLC" to get path of current item'

That returns the path to the currently playing movie. If you want more I suggest you select "Open Dictionary.." in the File menu of "Script Editor", select VLC and have a good look. Then do man osascript on the command line for the man page of osascript.