-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
omxplayer - checking status via dbus
- Loading branch information
Showing
14 changed files
with
164 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
#!/bin/bash | ||
|
||
#set -x | ||
|
||
OMXPLAYER_DBUS_ADDR="/tmp/omxplayerdbus.${USER:-root}" | ||
OMXPLAYER_DBUS_PID="/tmp/omxplayerdbus.${USER:-root}.pid" | ||
export DBUS_SESSION_BUS_ADDRESS=`cat $OMXPLAYER_DBUS_ADDR` | ||
export DBUS_SESSION_BUS_PID=`cat $OMXPLAYER_DBUS_PID` | ||
|
||
[ -z "$DBUS_SESSION_BUS_ADDRESS" ] && { echo "Must have DBUS_SESSION_BUS_ADDRESS" >&2; exit 1; } | ||
|
||
RTO="1500" # reply time-out | ||
|
||
IDX="$1" | ||
|
||
case $2 in | ||
status) | ||
duration=`dbus-send --print-reply=literal --session --reply-timeout=$RTO --dest=$IDX /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:"org.mpris.MediaPlayer2.Player" string:"Duration"` | ||
[ $? -ne 0 ] && exit 1 | ||
duration="$(awk '{print $2}' <<< "$duration")" | ||
|
||
position=`dbus-send --print-reply=literal --session --reply-timeout=$RTO --dest=$IDX /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:"org.mpris.MediaPlayer2.Player" string:"Position"` | ||
[ $? -ne 0 ] && exit 1 | ||
position="$(awk '{print $2}' <<< "$position")" | ||
|
||
playstatus=`dbus-send --print-reply=literal --session --reply-timeout=$RTO --dest=$IDX /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:"org.mpris.MediaPlayer2.Player" string:"PlaybackStatus"` | ||
[ $? -ne 0 ] && exit 1 | ||
playstatus="$(sed 's/^ *//;s/ *$//;' <<< "$playstatus")" | ||
|
||
paused="true" | ||
[ "$playstatus" == "Playing" ] && paused="false" | ||
echo "Duration: $duration" | ||
echo "Position: $position" | ||
echo "Paused: $paused" | ||
;; | ||
|
||
volume) | ||
volume=`dbus-send --print-reply=double --session --reply-timeout=$RTO --dest=$IDX /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Set string:"org.mpris.MediaPlayer2.Player" string:"Volume" ${2:+double:}$2` | ||
[ $? -ne 0 ] && exit 1 | ||
volume="$(awk '{print $2}' <<< "$volume")" | ||
echo "Volume: $volume" | ||
;; | ||
|
||
pause) | ||
dbus-send --print-reply=literal --session --dest=$IDX /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Action int32:16 >/dev/null | ||
;; | ||
|
||
stop) | ||
dbus-send --print-reply=literal --session --dest=$IDX /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Action int32:15 >/dev/null | ||
;; | ||
|
||
seek) | ||
dbus-send --print-reply=literal --session --dest=$IDX /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Seek int64:$3 >/dev/null | ||
;; | ||
|
||
setposition) | ||
dbus-send --print-reply=literal --session --dest=$IDX /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.SetPosition objpath:/not/used int64:$3 >/dev/null | ||
;; | ||
|
||
setalpha) | ||
dbus-send --print-reply=literal --session --dest=$IDX /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.SetAlpha objpath:/not/used int64:$3 >/dev/null | ||
;; | ||
|
||
setvideopos) | ||
dbus-send --print-reply=literal --session --dest=$IDX /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.VideoPos objpath:/not/used string:"$3 $4 $5 $6" >/dev/null | ||
;; | ||
|
||
setvideocroppos) | ||
dbus-send --print-reply=literal --session --dest=$IDX /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.SetVideoCropPos objpath:/not/used string:"$3 $4 $5 $6" >/dev/null | ||
;; | ||
|
||
setaspectmode) | ||
dbus-send --print-reply=literal --session --dest=$IDX /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.SetAspectMode objpath:/not/used string:"$3" >/dev/null | ||
;; | ||
|
||
hidevideo) | ||
dbus-send --print-reply=literal --session --dest=$IDX /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Action int32:28 >/dev/null | ||
;; | ||
|
||
unhidevideo) | ||
dbus-send --print-reply=literal --session --dest=$IDX /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Action int32:29 >/dev/null | ||
;; | ||
|
||
volumeup) | ||
dbus-send --print-reply=literal --session --dest=$IDX /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Action int32:18 >/dev/null | ||
;; | ||
|
||
volumedown) | ||
dbus-send --print-reply=literal --session --dest=$IDX /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Action int32:17 >/dev/null | ||
;; | ||
|
||
togglesubtitles) | ||
dbus-send --print-reply=literal --session --dest=$IDX /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Action int32:12 >/dev/null | ||
;; | ||
|
||
hidesubtitles) | ||
dbus-send --print-reply=literal --session --dest=$IDX /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Action int32:30 >/dev/null | ||
;; | ||
|
||
showsubtitles) | ||
dbus-send --print-reply=literal --session --dest=$IDX /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Action int32:31 >/dev/null | ||
;; | ||
getsource) | ||
source=$(dbus-send --print-reply=literal --session --reply-timeout=$RTO --dest=$IDX /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.GetSource) | ||
[ $? -ne 0 ] && exit 1 | ||
echo "$source" | sed 's/^ *//' | ||
;; | ||
*) | ||
echo "usage: $0 idx status|pause|stop|seek|volumeup|volumedown|setposition [position in microseconds]|hidevideo|unhidevideo|togglesubtitles|hidesubtitles|showsubtitles|setvideopos [x1 y1 x2 y2]|setvideocroppos [x1 y1 x2 y2]|setaspectmode [letterbox,fill,stretch,default]|setalpha [alpha (0..255)]|getsource" >&2 | ||
exit 1 | ||
;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,3 +32,5 @@ fi | |
|
||
ifconfig $IFACE 0.0.0.0 | ||
systemctl restart $SERVICE.service | ||
|
||
sync |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,5 @@ fi | |
amixer cset numid=$VOLUMEID $VOL% | ||
amixer cset numid=$AGCID 0 | ||
alsactl store | ||
|
||
sync |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,5 @@ fi | |
#amixer cset numid=$VOLUMEID $1% | ||
amixer cset numid=$VOLUMEID $VOL% | ||
alsactl store | ||
|
||
sync |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters