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>
This commit is contained in:
Friedemann Kleint
2016-03-01 14:58:18 +01:00
parent 1816f89b6f
commit 787211c1d2
3 changed files with 56 additions and 24 deletions

View File

@@ -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();