我在我的应用程序中启动诺基亚自己的视频播放器时,我似乎并不能够解决。

我的第一次尝试包括调用

Qt.openUrlExternally(url)
.

来自QML,这似乎只做了很好的事情,除了它每次打开浏览器并使用它而不是视频套件(本机播放器)。

下一个我尝试了cutetube - 我开始新的进程的......

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);
. 它的工作,除了它需要在召唤播放器 - >开始时要关闭视频套件,否则它没有。

我的第三次尝试涉及通过qdbus启动视频套件,但这并不更好地工作:

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";
}
.

此问题是它需要视频套件才能启动和运行 - AutoStartService参数也没有帮助。如果视频套件未运行,则呼叫将打开它,但是,唉,没有视频开始播放。

最终我还尝试使用 videoSuiteInterface ,但即使具有程序编译似乎是困难的。当我最终设法编译并链接所有相关库时,结果与上面的选项3不同。

所以,有没有办法直接或通过DBUS使用的方法,以便它将开始视频播放,而不管应用程序的当前状态如何?

有帮助吗?

解决方案

The solution was actually simpler than I really thought initially; the VideoSuiteInterface -approach worked after all. All it took was to use it properly. Here are the full sources should anyone want to try it 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 may want to connect some signals to make the UI more responsive, but basically that should do the trick.

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

CONFIG += videosuiteinterface-maemo-meegotouch
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top