Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. DBus connection to omxplayer won't work
Forum Updated to NodeBB v4.3 + New Features

DBus connection to omxplayer won't work

Scheduled Pinned Locked Moved Solved Mobile and Embedded
raspberry piomxplayer
4 Posts 2 Posters 3.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • fl0mllF Offline
    fl0mllF Offline
    fl0mll
    wrote on last edited by fl0mll
    #1

    Hy, I try to write a wrapper to navigate the omxplayer on raspberry pi 2. The script dbuscontroll.sh works but the Qt source code do not work.

    I am not sure if the application is connected? This is the code:

        QDBusConnection *_dbus;
        _dbus = new QDBusConnection(QDBusConnection::sessionBus());
        _dbus->connectToBus(address, "org.mpris.MediaPlayer2.omxplayer");
    
        if( !_dbus->isConnected() ) {
            qDebug() << "not connected";
        }
    
        QString dest = "org.mpris.MediaPlayer2.omxplayer";
        QString path = "/org/mpris/MediaPlayer2/";
        QString interface = "org.mpris.MediaPlayer2.Player";
        QString name = "Action";
        QDBusMessage msg = QDBusMessage::createMethodCall(dest, path, interface, name);
        msg.setArguments(QList<QVariant>() << 16);
        if( !_dbus->send(msg) ) {
            qWarning() << "error: " << _dbus->lastError().message();
        }
    

    And I got this output on the console:

    Unable to query physical screen size, defaulting to 100 dpi.
    To override, set QT_QPA_EGLFS_PHYSICAL_WIDTH and QT_QPA_EGLFS_PHYSICAL_HEIGHT (in millimeters).
    "unix:abstract=/tmp/dbus-FHoNnz9gMj"
    QDBusConnectionPrivate(0x72208478) : connected successfully
    not connected
    error:  "Not connected to D-Bus server"
    QDBusConnectionPrivate(0x72208478) got message (signal): QDBusMessage(type=Signal, service="org.freedesktop.DBus", path="/org/freedesktop/DBus", interface="org.freedesktop.DBus", member="NameAcquired", signature="s", contents=(":1.29") )
    

    I am connected with ssh and use the dbus-monitor. It display the following output:

    signal sender=org.freedesktop.DBus -> dest=(null destination) serial=8 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameOwnerChanged
       string ":1.33"
       string ""
       string ":1.33"
    method call sender=:1.33 -> dest=org.freedesktop.DBus serial=1 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=Hello
    

    Can anyone tell me what's going wrong and why the message is not queued?

    fl0mllF 1 Reply Last reply
    0
    • fl0mllF fl0mll

      Hy, I try to write a wrapper to navigate the omxplayer on raspberry pi 2. The script dbuscontroll.sh works but the Qt source code do not work.

      I am not sure if the application is connected? This is the code:

          QDBusConnection *_dbus;
          _dbus = new QDBusConnection(QDBusConnection::sessionBus());
          _dbus->connectToBus(address, "org.mpris.MediaPlayer2.omxplayer");
      
          if( !_dbus->isConnected() ) {
              qDebug() << "not connected";
          }
      
          QString dest = "org.mpris.MediaPlayer2.omxplayer";
          QString path = "/org/mpris/MediaPlayer2/";
          QString interface = "org.mpris.MediaPlayer2.Player";
          QString name = "Action";
          QDBusMessage msg = QDBusMessage::createMethodCall(dest, path, interface, name);
          msg.setArguments(QList<QVariant>() << 16);
          if( !_dbus->send(msg) ) {
              qWarning() << "error: " << _dbus->lastError().message();
          }
      

      And I got this output on the console:

      Unable to query physical screen size, defaulting to 100 dpi.
      To override, set QT_QPA_EGLFS_PHYSICAL_WIDTH and QT_QPA_EGLFS_PHYSICAL_HEIGHT (in millimeters).
      "unix:abstract=/tmp/dbus-FHoNnz9gMj"
      QDBusConnectionPrivate(0x72208478) : connected successfully
      not connected
      error:  "Not connected to D-Bus server"
      QDBusConnectionPrivate(0x72208478) got message (signal): QDBusMessage(type=Signal, service="org.freedesktop.DBus", path="/org/freedesktop/DBus", interface="org.freedesktop.DBus", member="NameAcquired", signature="s", contents=(":1.29") )
      

      I am connected with ssh and use the dbus-monitor. It display the following output:

      signal sender=org.freedesktop.DBus -> dest=(null destination) serial=8 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameOwnerChanged
         string ":1.33"
         string ""
         string ":1.33"
      method call sender=:1.33 -> dest=org.freedesktop.DBus serial=1 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=Hello
      

      Can anyone tell me what's going wrong and why the message is not queued?

      fl0mllF Offline
      fl0mllF Offline
      fl0mll
      wrote on last edited by
      #2

      I think that I found the solution. I will test something and post the result later.

      1 Reply Last reply
      0
      • fl0mllF Offline
        fl0mllF Offline
        fl0mll
        wrote on last edited by
        #3

        The solution is to set some environment variables. I set the address in qt but the environments are required for the libdbus library.

        Set the

        DBUS_SESSION_BUS_ADDRESS

        and

        DBUS_SESSION_BUS_PID

        1 Reply Last reply
        0
        • E Offline
          E Offline
          eluppai
          wrote on last edited by
          #4

          Hello,

          I am performing a similar operation. How are you actually passing the address ?

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved