From 8853575547c58e379e1fff17858147fc19039c5f Mon Sep 17 00:00:00 2001 From: Alexandre Moreno Date: Sun, 1 Nov 2015 16:32:55 +0800 Subject: [PATCH] playback/player: qt: accept a list of uris or files as command line parameters --- playback/player/qt/main.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/playback/player/qt/main.cpp b/playback/player/qt/main.cpp index 5634732f6f..999ddcba5e 100644 --- a/playback/player/qt/main.cpp +++ b/playback/player/qt/main.cpp @@ -20,6 +20,9 @@ #include #include +#include +#include +#include #include "player.h" @@ -27,6 +30,20 @@ int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); + QCommandLineParser parser; + parser.setApplicationDescription("GstPlayer"); + parser.addHelpOption(); + parser.addPositionalArgument("urls", + QCoreApplication::translate("main", "URLs to play, optionally."), "[urls...]"); + parser.process(app); + + QList media_files; + + const QStringList args = parser.positionalArguments(); + foreach (const QString file, args) { + media_files << QUrl::fromUserInput(file); + } + qmlRegisterType("Player", 1, 0, "Player"); /* the plugin must be loaded before loading the qml file to register the @@ -44,9 +61,12 @@ int main(int argc, char *argv[]) QObject *rootObject = engine.rootObjects().first(); Player *player = rootObject->findChild("player"); + QQuickItem *videoItem = rootObject->findChild("videoItem"); player->setVideoOutput(videoItem); + if (!media_files.isEmpty()) + player->setPlaylist(media_files); return app.exec(); }