richardcgiroux
Posts: 35
Joined: Sun May 15, 2016 1:54 pm

Controlling OMXPlayer via dbus from c or c++

Wed May 03, 2017 9:31 pm

I am trying to control OMXPlayer from my c/c++ program in order to speed up communication with the player. The batch file isn't fast enough for what I need.

Has anyone used c or c++ to send dbus commands to OMXPlayer?

User avatar
topguy
Posts: 6492
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Controlling OMXPlayer via dbus from c or c++

Wed May 03, 2017 10:01 pm

How fast do you need to be ?
And you have used dbus from bash ?

richardcgiroux
Posts: 35
Joined: Sun May 15, 2016 1:54 pm

Re: Controlling OMXPlayer via dbus from c or c++

Wed May 03, 2017 10:16 pm

I have used the control.sh batch file and sent commands directly from a shell terminal.


Pause command:

dbus-send --print-reply=literal --session --dest=org.mpris.MediaPlayer2.omxplayer /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Action int32:35 >/dev/null

What I need to do use a slider bar to scroll through the video. The dbus-send command is a little sluggish in instances like this.

If I could get it to respond quickly enough, I might even be able to present a preview window like in the YouTube player app on Android.

gkreidl
Posts: 6326
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: Controlling OMXPlayer via dbus from c or c++

Thu May 04, 2017 5:32 am

This won't work because omxplayer won't follow it: it will show the new time (position), but not start the video in each new position.

Simple test: run a video and keep the right arrow key pressed.
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

User avatar
topguy
Posts: 6492
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Controlling OMXPlayer via dbus from c or c++

Thu May 04, 2017 8:52 am

If you are considering going down the C/C++ path you might as well try to rewrite omxplayer itself and bypass dbus completely.

richardcgiroux
Posts: 35
Joined: Sun May 15, 2016 1:54 pm

Re: Controlling OMXPlayer via dbus from c or c++

Thu May 04, 2017 8:29 pm

I guess I was asking of anyone has sent dbus commands to OMXPlayer from code.

I don't think I need to rewrite OMXPlayer (that would take a while) since it has everything I need. I can call control.sh from my main code to control OMXPLayer and the setposition command does work. It is just a little sluggish.

I just need to learn dbus is guess.

Any examples of using dbus would be helpful.

paulslocum
Posts: 75
Joined: Sun Apr 09, 2017 10:54 pm

Re: Controlling OMXPlayer via dbus from c or c++

Sat May 13, 2017 8:38 pm

It's likely that the lag you're experiencing is from Omxplayer seeking and rebuffering rather than from dbus itself. You might be able to improve performance by reducing the buffer sizes. The Omxplayer main loop also has some sleep commands that may be slowing down dbus response time, or causing commands to pile up if you're sending them at a high rate.

Return to “C/C++”