注册 登录
自由的生活_软路由 返回首页

心想事成的个人空间 https://www.routerclub.com/?681 [收藏] [复制] [分享] [RSS]

日志

使用dbus控制vlc的播放

已有 90 次阅读2024-4-11 21:12

 

Using D-Bus interfaceSee freedesktop specification

Method call
Play / pause : dbus-send --type=method_call --dest=org.mpris.MediaPlayer2.vlc /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause
Seek 2s forward: dbus-send --type=method_call --dest=org.mpris.MediaPlayer2.vlc /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Seek int64:2000000
Seek 2s backward: dbus-send --type=method_call --dest=org.mpris.MediaPlayer2.vlc /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Seek int64:-2000000

dbus-send --print-reply --dest=org.mpris.MediaPlayer2.vlc /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next

dbus-send --print-reply --dest=org.mpris.MediaPlayer2.vlc /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous

Get property
dbus-send --dest=org.mpris.MediaPlayer2.vlc --print-reply /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:org.mpris.MediaPlayer2.Player string:PlaybackStatus
dbus-send --dest=org.mpris.MediaPlayer2.vlc --print-reply /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:org.mpris.MediaPlayer2.Player string:Volume
dbus-send --dest=org.mpris.MediaPlayer2.vlc --print-reply /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:org.mpris.MediaPlayer2.Player string:Metadata

Set property
dbus-send --dest=org.mpris.MediaPlayer2.vlc --print-reply /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Set string:org.mpris.MediaPlayer2.Player string:Volume variant:double:0.5

Basic Python example

from pydbus import SessionBus
bus = SessionBus()

# Create an object that will proxy for a particular remote object.
remote_object = bus.get(
	'org.mpris.MediaPlayer2.vlc', # Bus name
	'/org/mpris/MediaPlayer2'     # Object path
)

print(remote_object.PlaybackStatus)
print(remote_object.Volume)

remote_object.PlayPause()

print("Introspection data:\n")
print(remote_object.Introspect())

Using HTTP interfacehttp://localhost:8080/ ☺

Note: A password may be required.

Some cURL commands

With password "mypass"

  • Toggle pause: curl --user :mypass http://localhost:8080/requests/status.xml?command=pl_pause
  • Full status: curl -s --user :mypass http://localhost:8080/requests/status.xml
  • Song name: curl -s --user :mypass http://localhost:8080/requests/status.xml | xmllint --xpath "//info[@name='filename']/text()" -

VLC config for playing videos from beamer

Tested with VLC v3.0.8

echo "Reset config"
vlc --reset-config vlc://quit

echo "Don't ask for network policy at startup"
sed -i "s/#qt-privacy-ask=1/qt-privacy-ask=0/" ~/.config/vlc/vlcrc

echo "Fullscreen (tools / preferences / video / fullscreen)"
sed -i "s/#fullscreen=0/fullscreen=1/" ~/.config/vlc/vlcrc

echo "play and exit (in media menu)"
sed -i "s/#play-and-exit=0/play-and-exit=1/" ~/.config/vlc/vlcrc

echo "Always on top (Preferences / All / Video / Always on top)"
sed -i "s/#video-on-top=0/video-on-top=1/" ~/.config/vlc/vlcrc

echo "Disable video title (Preferences / All / Video / Show media title on video)"
sed -i "s/#video-title-show=1/video-title-show=0/" ~/.config/vlc/vlcrc


路过

雷人

握手

鲜花

鸡蛋

评论 (0 个评论)

facelist doodle 涂鸦板

您需要登录后才可以评论 登录 | 注册

QQ|Archiver|手机版|小黑屋|软路由 ( 渝ICP备15001194号-1|渝公网安备 50011602500124号 )

GMT+8, 2024-5-20 23:02 , Processed in 0.036176 second(s), 5 queries , Gzip On, Redis On.

Powered by Discuz! X3.5 Licensed

© 2001-2023 Discuz! Team.

返回顶部