0

So I have a Python script that runs a system call that fetches some inputs and does some calculations before it loads up a playlist.

I run this script first to load up VLC media player

start vlc --random --loop --playlist-autostart --qt-start-minimized --one-instance --mmdevice-volume=0.35

I then loop through my playlist running this code on each file I want to add to my VLC player

vlc --one-instance --playlist-enqueue "X:\Music\filename.mp3"

The weird thing being that, when I run the program initially, only the first file gets added to the playlist and my Prompt is blocked. Only after I close the vlc player does the next song get fired up again.
So I usually close the script and execute it again and this time it loads the entire playlist in one go.

What is going on here ?

4
  • What output do you get if you run the VLC commands manually? Rather than running the VLC commands from python just print them and run them one by one yourself.
    – Mokubai
    Commented May 3, 2021 at 10:43
  • the first command starts the vlc player, second one adds the track to the playlist. But that's okay, the issue is when I run the loop, instead of adding all the tracks in one go. It adds ONLY one track and then waits for me to close the vlc window. It blocks the CLI...
    – Jitin
    Commented May 3, 2021 at 20:14
  • So run the loop manually, see if it throws up the same errors. If it is a problem in your program generating the code for the loop then it would be off topic here and I am trying to encourage you to find out if the problem is with VLC or with your code. If you can reproduce the problem on the command line away from Python then it is on topic here. As an absolute minimum having command line output or errors, if any, might be useful.
    – Mokubai
    Commented May 3, 2021 at 21:24
  • the problem when I load it manually is that it does not start playing. so i need the tracks to be loaded at the same time the vlc window is opened
    – Jitin
    Commented May 4, 2021 at 15:00

1 Answer 1

0

What is going on here?

In my experience, using scripts to play items from the command line with VLC is prone to inconsistency on Windows. In particular, vlc --one-instance --playlist-enqueue seems sensitive to other instances of VLC and how they were started.

The behavior that you describe (VLC loads one item and blocks the command prompt until closed) can happen when VLC is run with just vlc (rather than after an initial instance with start vlc).

My guess would be that (for whatever reason), your start vlc command may be encountering a small delay and the Python script is moving on to simply running vlc in your loop (meaning vlc is run before start vlc finishes, so that start vlc is ignored by VLC). However, it's additional runs may benefit from some kind of caching, so that delay isn't always encountered.

2
  • okay so I added start vlc to all my commands and also added a small delay before it loads the playlist. it works now. Thank You
    – Jitin
    Commented May 14, 2021 at 5:32
  • Glad to assist. =) Commented May 14, 2021 at 10:29

You must log in to answer this question.

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