diff options
Diffstat (limited to 'playback/player/qt/main.cpp')
-rw-r--r-- | playback/player/qt/main.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/playback/player/qt/main.cpp b/playback/player/qt/main.cpp index 5634732..999ddcb 100644 --- a/playback/player/qt/main.cpp +++ b/playback/player/qt/main.cpp @@ -20,6 +20,9 @@ #include <QApplication> #include <QQmlApplicationEngine> +#include <QCommandLineParser> +#include <QStringList> +#include <QUrl> #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<QUrl> media_files; + + const QStringList args = parser.positionalArguments(); + foreach (const QString file, args) { + media_files << QUrl::fromUserInput(file); + } + qmlRegisterType<Player>("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*>("player"); + QQuickItem *videoItem = rootObject->findChild<QQuickItem*>("videoItem"); player->setVideoOutput(videoItem); + if (!media_files.isEmpty()) + player->setPlaylist(media_files); return app.exec(); } |