diff options
author | Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> | 2016-03-01 14:58:18 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> | 2016-03-01 14:59:17 +0000 |
commit | 787211c1d2082874ea07be4c5987032221ee48fe (patch) | |
tree | 158e1fa111b47ca8c415a4e5b59ce15ac8be6f4c /examples/multimediawidgets/player/main.cpp | |
parent | 1816f89b6fc1f62ea2b97fabf43963b3312a7c08 (diff) |
Polish the QtWidgets/Player example.
Point the file dialog to the Movies folder.
Add command proper command line handling.
Change the logic to use QUrl everywhere.
Change-Id: I1e54e600187153f52a55e3a381a24e4f2eeda3ab
Reviewed-by: Yoann Lopes <yoann.lopes@theqtcompany.com>
Diffstat (limited to 'examples/multimediawidgets/player/main.cpp')
-rw-r--r-- | examples/multimediawidgets/player/main.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/examples/multimediawidgets/player/main.cpp b/examples/multimediawidgets/player/main.cpp index c32cbc83e..a3dabe15d 100644 --- a/examples/multimediawidgets/player/main.cpp +++ b/examples/multimediawidgets/player/main.cpp @@ -41,13 +41,33 @@ #include "player.h" #include <QApplication> +#include <QCommandLineParser> +#include <QCommandLineOption> +#include <QDir> int main(int argc, char *argv[]) { QApplication app(argc, argv); + QCoreApplication::setApplicationName("Player Example"); + QCoreApplication::setOrganizationName("QtProject"); + QCoreApplication::setApplicationVersion(QT_VERSION_STR); + QCommandLineParser parser; + parser.setApplicationDescription("Qt MultiMedia Player Example"); + parser.addHelpOption(); + parser.addVersionOption(); + parser.addPositionalArgument("url", "The URL to open."); + parser.process(app); + Player player; + if (!parser.positionalArguments().isEmpty() && player.isPlayerAvailable()) { + QList<QUrl> urls; + foreach (const QString &a, parser.positionalArguments()) + urls.append(QUrl::fromUserInput(a, QDir::currentPath(), QUrl::AssumeLocalFile)); + player.addToPlaylist(urls); + } + #if defined(Q_WS_SIMULATOR) player.setAttribute(Qt::WA_LockLandscapeOrientation); player.showMaximized(); |