The plan was to put all those peaces together and make a remote control for this media player. I started a project, which you can find here: https://bitbucket.org/nchokoev/qtsshremote.
The remote control uses dbus commands over ssh to control the gnome-mplayer.
First thing is to connect to the host and establish ssh connection and get ansi terminal. It's nice to use a terminal as we can see when the command is completed. For this I'm using a little trick - I'm changing the prompt string. Once I receive this string I know the command is executed.
The first command is to set the xorg display environment variable:
"export DISPLAY=:0\n"
To check if there is gnome-mplayer running I'm using the following code. It checks the running processes for 'gnome-mplayer' and gets their PIDs.
"pgrep gnome-mplayer\n"
Setting DBUS_SESSION_BUS_ADDRESS:
QString s = "$(tr '\' '\\n' < /proc/$(pgrep gnome-mplayer | head -1 )/environ | sed -e 's/^/export /')\n";
execSSHCmd((char*)s.toUtf8().constData(),s.size(), buf, 0);
s = "echo $DBUS_SESSION_BUS_ADDRESS\n";
execSSHCmd((char*)s.toUtf8().constData(),s.size(), buf, 0);
To get the files and folders I'm using 'ls' command. The only difference is that I force the output to be an entry per line (-1) and no colours (--color=none). It makes much easier the output parsing.
"ls -1 --color=none\n"
The other part of the code is pretty straight forward. It uses the gnome-mplayer dbus messages to control the player.
The nice thing is that it is very easy to open and close the player as well as navigate the the desired media file and play it.
You can download the code and use it without any restrictions. However, I'll appreciate if you leave a feedback or if you send me any modifications you've made.
I hope you find it useful.
Subscribe for our NewsLetter!
I downloaded source and i tried build it, but i have some issues. Could you give me some advice how i should build this project?
ReplyDeleteDid you get the libssh2 as well? What kind of issues you have?
ReplyDelete