How to run a video package in MeeGo / Nokia N9 from Qt-code?

I'm having problems launching my own Nokia video player from my application, which I just can't solve.

My first attempt included a call

Qt.openUrlExternally(url) 

from QML, and this seemed to do the trick just fine, except that every time it opened the browser and used it instead of the video package (main player).

Next I tried cuteTube-Approach, where I start a new process as follows:

 QStringList args; args << url; QProcess *player = new QProcess(); connect(player, SIGNAL(finished(int, QProcess::ExitStatus)), player, SLOT(deleteLater())); player->start("/usr/bin/video-suite", args); 

This worked, except that to call the player-> start function, it was necessary to close the video package, otherwise it did nothing.

My third attempt included launching a video package through QDBus, but this did not help:

 QList<QVariant> args; QStringList urls; urls << url; args.append(urls); QDBusMessage message = QDBusMessage::createMethodCall( "com.nokia.VideoSuite", "/", "com.nokia.maemo.meegotouch.VideoSuiteInterface", "play"); message.setArguments(args); message.setAutoStartService(true); QDBusConnection bus = QDBusConnection::sessionBus(); if (bus.isConnected()) { bus.send(message); } else { qDebug() << "Error, QDBus is not connected"; } 

The problem is that this requires the video set to be up and running - the autoStartService parameter did not help either. If the video package is not already running, the call opens it just fine, but, alas, the video does not start playing.

In the end, I tried to use VideoSuiteInterface as well , but even with compiling a program with it seemed difficult. When I eventually managed to collect and link all the relevant libraries, the results did not differ from option 3 above.

So, is there a way to use VideoSuiteInterface directly or via DBus so that it starts playing video regardless of the current state of the application?

+4
source share
1 answer

The solution was actually simpler than I originally thought; VideoSuiteInterface -approach worked in the end. All you need is to use it correctly. Here are the complete sources if someone wants to try it for themselves.

player.h:

 #ifndef PLAYER_H #define PLAYER_H #include <QObject> #include <maemo-meegotouch-interfaces/videosuiteinterface.h> class Player : public QObject { Q_OBJECT private: VideoSuiteInterface* videosuite; public: Player(QObject *parent = 0); Q_INVOKABLE void play(QString url); }; #endif // PLAYER_H 

player.cpp:

 #include "player.h" #include <QObject> #include <QStringList> #include <QtDeclarative> Player::Player(QObject *parent) : QObject(parent) {} void Player::play(QString url) { QList<QVariant> args; QStringList urls; urls << url; args.append(urls); videosuite = new VideoSuiteInterface(); videosuite->play(urls); } 

In addition, you can connect some signals to make the interface more responsive, but basically this should do the trick.

Finally, you need to remember that you need to add the following to your .pro file, and you are good to go:

 CONFIG += videosuiteinterface-maemo-meegotouch 
+1
source

Source: https://habr.com/ru/post/1399057/


All Articles