mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
playback/player: qt: accept a list of uris or files as command line parameters
This commit is contained in:
parent
1cebdf926c
commit
8853575547
1 changed files with 20 additions and 0 deletions
|
@ -20,6 +20,9 @@
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QQmlApplicationEngine>
|
#include <QQmlApplicationEngine>
|
||||||
|
#include <QCommandLineParser>
|
||||||
|
#include <QStringList>
|
||||||
|
#include <QUrl>
|
||||||
|
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
|
|
||||||
|
@ -27,6 +30,20 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QGuiApplication app(argc, 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");
|
qmlRegisterType<Player>("Player", 1, 0, "Player");
|
||||||
|
|
||||||
/* the plugin must be loaded before loading the qml file to register the
|
/* 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();
|
QObject *rootObject = engine.rootObjects().first();
|
||||||
|
|
||||||
Player *player = rootObject->findChild<Player*>("player");
|
Player *player = rootObject->findChild<Player*>("player");
|
||||||
|
|
||||||
QQuickItem *videoItem = rootObject->findChild<QQuickItem*>("videoItem");
|
QQuickItem *videoItem = rootObject->findChild<QQuickItem*>("videoItem");
|
||||||
player->setVideoOutput(videoItem);
|
player->setVideoOutput(videoItem);
|
||||||
|
|
||||||
|
if (!media_files.isEmpty())
|
||||||
|
player->setPlaylist(media_files);
|
||||||
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue