From a6a152acdc0076a61a43ed284fade6fae35b3f38 Mon Sep 17 00:00:00 2001 From: Tobias Fella Date: Fri, 7 Oct 2022 09:56:08 +0000 Subject: [PATCH] Also fix video resolution in qt5 Replaces !395 Fixes #120 --- src/neochatroom.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/neochatroom.cpp b/src/neochatroom.cpp index a3101c43c..1d4f8b256 100644 --- a/src/neochatroom.cpp +++ b/src/neochatroom.cpp @@ -11,10 +11,8 @@ #include #include -#if QT_VERSION > QT_VERSION_CHECK(6, 0, 0) #include #include -#endif #include #include @@ -99,7 +97,6 @@ QCoro::Task NeoChatRoom::doUploadFile(QUrl url, QString body) co_return; } -#if QT_VERSION > QT_VERSION_CHECK(6, 0, 0) auto mime = QMimeDatabase().mimeTypeForUrl(url); QFileInfo fileInfo(url.toLocalFile()); EventContent::TypedBase *content; @@ -110,13 +107,22 @@ QCoro::Task NeoChatRoom::doUploadFile(QUrl url, QString body) content = new EventContent::AudioContent(url, fileInfo.size(), mime, fileInfo.fileName()); } else if (mime.name().startsWith("video/")) { QMediaPlayer player; +#if QT_VERSION > QT_VERSION_CHECK(6, 0, 0) player.setSource(url); +#else + player.setMedia(url); +#endif co_await qCoro(&player, &QMediaPlayer::mediaStatusChanged); +#if QT_VERSION > QT_VERSION_CHECK(6, 0, 0) auto resolution = player.metaData().value(QMediaMetaData::Resolution).toSize(); +#else + auto resolution = player.metaData(QMediaMetaData::Resolution).toSize(); +#endif content = new EventContent::VideoContent(url, fileInfo.size(), mime, resolution, fileInfo.fileName()); } else { content = new EventContent::FileContent(url, fileInfo.size(), mime, fileInfo.fileName()); } +#ifdef QUOTIENT_07 QString txnId = postFile(body.isEmpty() ? url.fileName() : body, content); #else QString txnId = postFile(body.isEmpty() ? url.fileName() : body, url, false);