Open VLC viewer in Python
I am trying to make a python program to open the VLC File Viewer Window on Ubuntu
global process
import io,sys,os
import subprocess
myprocess = subprocess.call(['vlc','/home/tansen'])
but the above code just opens "VLC Player" and not a file open window Can you advise me how to get the desired result? I add also an opening image for vlc input
thank
according to the documentation , the correct syntax should be
vlc -vvv video.mp4
and the python code you can use is
subprocess.POPEN(['vlc', '-vvv', '/path/to/video.mp4'])
You can also add PIPE
to dump output from vlc.
source to share
What OS platform?
On Linux: If you run qdbusviewer, you will see the dbus methods available. I don't see one to display the file dialog, but there is one to open the url:
qdbus org.mpris.MediaPlayer2.vlc /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.OpenUri test.mp3
So from Python:
import subprocess
subprocess.call(["qdbus", "org.mpris.MediaPlayer2.vlc", "/org/mpris/MediaPlayer2", "org.mpris.MediaPlayer2.Player.OpenUri", "file:///home/john/test.mp3"])'
Or:
import gobject
gobject.threads_init()
from dbus import glib
glib.init_threads()
import dbus
bus = dbus.SessionBus()
obj = bus.get_object("org.mpris.MediaPlayer2.vlc", "/org/mpris/MediaPlayer2")
iface = dbus.Interface(obj, "org.mpris.MediaPlayer2.Player")
iface.OpenUri("file:///home/john/test.mp3")
On Windows: Try COM?
source to share