I am trying to write a simple program in Python on Ubuntu that will close/exit/quit VLC Player when playing video has completed.
Can you please guide me that what should I add in my program to get my required result.
import io,sys,os,subprocess
from tkFileDialog import askopenfilename
global process
name= askopenfilename(filetypes=[("Video Files","*.h264")])
myprocess = subprocess.call(['vlc',name])
Thank you
Use VLC's --play-and-exit command line option as so:
subprocess.call(['vlc',name,'--play-and-exit'])
so your final code would look like:
import io,sys,os,subprocess
from tkFileDialog import askopenfilename
global process
name= askopenfilename(filetypes=[("Video Files","*.h264")])
subprocess.call(['vlc',name,'--play-and-exit'])
[Note:] You may have to set shell to True or False for it to work properly as so:
shell_value = False # or True
subprocess.call(['vlc',name,'--play-and-exit'], shell=shell_value)
[Alternative:] You can also instead include vlc://quit as the last 'file' to play as so:
subprocess.call(['vlc',name,'vlc://quit'])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With