summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorshi ce <shic.fnst@fujitsu.com>2021-05-14 11:34:28 +0800
committershi ce <shic.fnst@fujitsu.com>2021-05-14 11:40:08 +0800
commit54da9d4383a999d2dc2223e7e5215444e04c3f32 (patch)
tree51daffffab7a91ad6a3cbf831aac89e4d86004cc /app
parent6241a8991b4490f6cdc33b395df83f88898b6415 (diff)
in addition, modified the code Bug-AGL: SPEC-3458 Change-Id: I6d0a6d8e4498464f7fff2c7065fcecfb68cc5227 Signed-off-by: shi ce <shic.fnst@fujitsu.com>
Diffstat (limited to 'app')
-rw-r--r--app/app.pro2
-rw-r--r--app/main.cpp55
2 files changed, 50 insertions, 7 deletions
diff --git a/app/app.pro b/app/app.pro
index eeb139c..0083bfc 100644
--- a/app/app.pro
+++ b/app/app.pro
@@ -1,5 +1,5 @@
TARGET = videoplayer
-QT = quick aglextras multimedia
+QT = quick websockets multimedia
SOURCES = main.cpp
diff --git a/app/main.cpp b/app/main.cpp
index 7fdff20..11b1230 100644
--- a/app/main.cpp
+++ b/app/main.cpp
@@ -13,14 +13,57 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include <QtAGLExtras/AGLApplication>
#include <QtQml/QQmlApplicationEngine>
+#include <QtGui/QGuiApplication>
+#include <QDebug>
+#include <QUrlQuery>
+#include <QCommandLineParser>
+#include <QtQml/QQmlContext>
+
int main(int argc, char *argv[])
{
- AGLApplication app(argc, argv);
- app.setApplicationName("VideoPlayer");
- app.setupApplicationRole("Video");
- app.load(QUrl(QStringLiteral("qrc:/VideoPlayer.qml")));
- return app.exec();
+
+ setenv("QT_QPA_PLATFORM", "wayland", 1);
+ int port;
+ QString token;
+
+ QCommandLineParser parser;
+ QGuiApplication app(argc, argv);
+
+ parser.addPositionalArgument("port",
+ app.translate("main", "port for binding"));
+ parser.addPositionalArgument("secret",
+ app.translate("main", "secret for binding"));
+
+ parser.addHelpOption();
+ parser.addVersionOption();
+ parser.process(app);
+ QStringList positionalArguments = parser.positionalArguments();
+
+ if (positionalArguments.length() == 2) {
+ port = positionalArguments.takeFirst().toInt();
+ token = positionalArguments.takeFirst();
+ qInfo() << "setting port:" << port << ", token:" << token;
+ } else {
+ qInfo() << "Need to specify port and token";
+ exit(EXIT_FAILURE);
+ }
+
+ QUrl bindingAddress;
+ bindingAddress.setScheme(QStringLiteral("ws"));
+ bindingAddress.setHost(QStringLiteral("localhost"));
+ bindingAddress.setPort(port);
+ bindingAddress.setPath(QStringLiteral("/api"));
+
+ QUrlQuery query;
+ query.addQueryItem(QStringLiteral("token"), token);
+ bindingAddress.setQuery(query);
+
+ QQmlApplicationEngine engine;
+ engine.rootContext()->setContextProperty(QStringLiteral("bindingAddress"), bindingAddress);
+ engine.load(QUrl(QStringLiteral("qrc:/VideoPlayer.qml")));
+
+ return app.exec();
+
}