@@ -11,10 +11,8 @@
|
|||||||
#include <QTextDocument>
|
#include <QTextDocument>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
#if QT_VERSION > QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
#include <QMediaMetaData>
|
#include <QMediaMetaData>
|
||||||
#include <QMediaPlayer>
|
#include <QMediaPlayer>
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <qcoro/qcorosignal.h>
|
#include <qcoro/qcorosignal.h>
|
||||||
#include <qcoro/task.h>
|
#include <qcoro/task.h>
|
||||||
@@ -99,7 +97,6 @@ QCoro::Task<void> NeoChatRoom::doUploadFile(QUrl url, QString body)
|
|||||||
co_return;
|
co_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if QT_VERSION > QT_VERSION_CHECK(6, 0, 0)
|
|
||||||
auto mime = QMimeDatabase().mimeTypeForUrl(url);
|
auto mime = QMimeDatabase().mimeTypeForUrl(url);
|
||||||
QFileInfo fileInfo(url.toLocalFile());
|
QFileInfo fileInfo(url.toLocalFile());
|
||||||
EventContent::TypedBase *content;
|
EventContent::TypedBase *content;
|
||||||
@@ -110,13 +107,22 @@ QCoro::Task<void> NeoChatRoom::doUploadFile(QUrl url, QString body)
|
|||||||
content = new EventContent::AudioContent(url, fileInfo.size(), mime, fileInfo.fileName());
|
content = new EventContent::AudioContent(url, fileInfo.size(), mime, fileInfo.fileName());
|
||||||
} else if (mime.name().startsWith("video/")) {
|
} else if (mime.name().startsWith("video/")) {
|
||||||
QMediaPlayer player;
|
QMediaPlayer player;
|
||||||
|
#if QT_VERSION > QT_VERSION_CHECK(6, 0, 0)
|
||||||
player.setSource(url);
|
player.setSource(url);
|
||||||
|
#else
|
||||||
|
player.setMedia(url);
|
||||||
|
#endif
|
||||||
co_await qCoro(&player, &QMediaPlayer::mediaStatusChanged);
|
co_await qCoro(&player, &QMediaPlayer::mediaStatusChanged);
|
||||||
|
#if QT_VERSION > QT_VERSION_CHECK(6, 0, 0)
|
||||||
auto resolution = player.metaData().value(QMediaMetaData::Resolution).toSize();
|
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());
|
content = new EventContent::VideoContent(url, fileInfo.size(), mime, resolution, fileInfo.fileName());
|
||||||
} else {
|
} else {
|
||||||
content = new EventContent::FileContent(url, fileInfo.size(), mime, fileInfo.fileName());
|
content = new EventContent::FileContent(url, fileInfo.size(), mime, fileInfo.fileName());
|
||||||
}
|
}
|
||||||
|
#ifdef QUOTIENT_07
|
||||||
QString txnId = postFile(body.isEmpty() ? url.fileName() : body, content);
|
QString txnId = postFile(body.isEmpty() ? url.fileName() : body, content);
|
||||||
#else
|
#else
|
||||||
QString txnId = postFile(body.isEmpty() ? url.fileName() : body, url, false);
|
QString txnId = postFile(body.isEmpty() ? url.fileName() : body, url, false);
|
||||||
|
|||||||
Reference in New Issue
Block a user