Max Tet
Max Tet

Reputation: 755

Python: Start media playback in new parallel process

For a small media library which allows me to rate media while it is playing i need to run the media and a python shell simultaniously. This is what I had in mind:

def play(path):
  os.execlp("vlc.exe", "vlc.exe", path)

process = multiprocessing.Process(target=play, args=(somePath,))
process.start()
input("Press Enter to kill process")
process.terminate()

The shell works as inteded, but nothing is played. VLC is not started.

If I directly call play, vlc is started an the media starts playing. But then of course I loose control over the python shell.

Upvotes: 0

Views: 210

Answers (1)

Jakob Bowyer
Jakob Bowyer

Reputation: 34698

Open it as a subprocess using the subprocess module

subprocess.call('vlc.exe my video')

Upvotes: 1

Related Questions