mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-25 04:28:49 +03:00
parent
131c64ecde
commit
61d2d1c665
3 changed files with 40 additions and 16 deletions
|
@ -67,6 +67,7 @@ Item {
|
|||
fillMode: VideoOutput.PreserveAspectFit
|
||||
source: mxcmedia
|
||||
flushMode: VideoOutput.FirstFrame
|
||||
orientation: mxcmedia.orientation
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QMediaMetaData>
|
||||
#include <QMediaObject>
|
||||
#include <QMediaPlayer>
|
||||
#include <QMimeDatabase>
|
||||
|
@ -23,6 +24,28 @@
|
|||
#include "MatrixClient.h"
|
||||
#include "timeline/TimelineModel.h"
|
||||
|
||||
MxcMediaProxy::MxcMediaProxy(QObject *parent)
|
||||
: QMediaPlayer(parent)
|
||||
{
|
||||
connect(this, &MxcMediaProxy::eventIdChanged, &MxcMediaProxy::startDownload);
|
||||
connect(this, &MxcMediaProxy::roomChanged, &MxcMediaProxy::startDownload);
|
||||
connect(this,
|
||||
qOverload<QMediaPlayer::Error>(&MxcMediaProxy::error),
|
||||
[this](QMediaPlayer::Error error) {
|
||||
nhlog::ui()->info("Media player error {} and errorStr {}",
|
||||
error,
|
||||
this->errorString().toStdString());
|
||||
});
|
||||
connect(this, &MxcMediaProxy::mediaStatusChanged, [this](QMediaPlayer::MediaStatus status) {
|
||||
nhlog::ui()->info("Media player status {} and error {}", status, this->error());
|
||||
});
|
||||
connect(this,
|
||||
qOverload<const QString &, const QVariant &>(&MxcMediaProxy::metaDataChanged),
|
||||
[this](QString t, QVariant) {
|
||||
if (t == QMediaMetaData::Orientation)
|
||||
emit orientationChanged();
|
||||
});
|
||||
}
|
||||
void
|
||||
MxcMediaProxy::setVideoSurface(QAbstractVideoSurface *surface)
|
||||
{
|
||||
|
@ -37,6 +60,15 @@ MxcMediaProxy::getVideoSurface()
|
|||
return m_surface;
|
||||
}
|
||||
|
||||
int
|
||||
MxcMediaProxy::orientation() const
|
||||
{
|
||||
nhlog::ui()->debug("metadata: {}", availableMetaData().join(",").toStdString());
|
||||
auto orientation = metaData(QMediaMetaData::Orientation).toInt();
|
||||
nhlog::ui()->debug("Video orientation: {}", orientation);
|
||||
return orientation;
|
||||
}
|
||||
|
||||
void
|
||||
MxcMediaProxy::startDownload()
|
||||
{
|
||||
|
|
|
@ -25,23 +25,10 @@ class MxcMediaProxy : public QMediaPlayer
|
|||
Q_PROPERTY(QString eventId READ eventId WRITE setEventId NOTIFY eventIdChanged)
|
||||
Q_PROPERTY(QAbstractVideoSurface *videoSurface READ getVideoSurface WRITE setVideoSurface)
|
||||
Q_PROPERTY(bool loaded READ loaded NOTIFY loadedChanged)
|
||||
Q_PROPERTY(int orientation READ orientation NOTIFY orientationChanged)
|
||||
|
||||
public:
|
||||
MxcMediaProxy(QObject *parent = nullptr)
|
||||
: QMediaPlayer(parent)
|
||||
{
|
||||
connect(this, &MxcMediaProxy::eventIdChanged, &MxcMediaProxy::startDownload);
|
||||
connect(this, &MxcMediaProxy::roomChanged, &MxcMediaProxy::startDownload);
|
||||
connect(this,
|
||||
qOverload<QMediaPlayer::Error>(&MxcMediaProxy::error),
|
||||
[this](QMediaPlayer::Error error) {
|
||||
nhlog::ui()->info("Media player error {} and errorStr {}",
|
||||
error,
|
||||
this->errorString().toStdString());
|
||||
});
|
||||
connect(this, &MxcMediaProxy::mediaStatusChanged, [this](QMediaPlayer::MediaStatus status) {
|
||||
nhlog::ui()->info("Media player status {} and error {}", status, this->error());
|
||||
});
|
||||
}
|
||||
MxcMediaProxy(QObject *parent = nullptr);
|
||||
|
||||
bool loaded() const { return buffer.size() > 0; }
|
||||
QString eventId() const { return eventId_; }
|
||||
|
@ -59,12 +46,16 @@ public:
|
|||
void setVideoSurface(QAbstractVideoSurface *surface);
|
||||
QAbstractVideoSurface *getVideoSurface();
|
||||
|
||||
int orientation() const;
|
||||
|
||||
signals:
|
||||
void roomChanged();
|
||||
void eventIdChanged();
|
||||
void loadedChanged();
|
||||
void newBuffer(QMediaContent, QIODevice *buf);
|
||||
|
||||
void orientationChanged();
|
||||
|
||||
private slots:
|
||||
void startDownload();
|
||||
|
||||
|
|
Loading…
Reference in a new issue