plhabj workding

This commit is contained in:
Dark Steveneq
2025-10-18 23:00:53 +02:00
parent 6fc0736c2d
commit c91fba3ee2
3 changed files with 31 additions and 14 deletions

View File

@@ -9,8 +9,8 @@ Rectangle {
visible: Player.hasVideo visible: Player.hasVideo
color: Colors.surface1 color: Colors.surface1
width: childrenRect.width // width: childrenRect.width
height: childrenRect.height height: 64
ColumnLayout { ColumnLayout {
anchors.fill: parent anchors.fill: parent

View File

@@ -4,18 +4,23 @@ import QtQuick.Layouts 6.8
import QYRComponents 1.0 import QYRComponents 1.0
Item { ColumnLayout {
anchors.fill: parent anchors.fill: parent
property bool loading: true property bool loading: true
property bool failed: false property bool failed: false
VideoPlayer {} VideoPlayer {
Layout.fillWidth: true
Layout.fillHeight: false
}
GridView { GridView {
anchors.horizontalCenter: parent.horizontalCenter Layout.fillWidth: true
Layout.fillHeight: true
// anchors.horizontalCenter: parent.horizontalCenter
visible: !loading || !failed visible: !loading || !failed
anchors.fill: parent // anchors.fill: parent
model: ListModel { id: model } model: ListModel { id: model }
clip: true clip: true

View File

@@ -65,7 +65,12 @@ void Player::loadVideo(QString id)
{ {
this->unloadVideo(); this->unloadVideo();
} }
const QNetworkReply* reply = this->manager.get(QNetworkRequest(QUrl("https://youvideo.nonamesoft.xyz/youvideo/video/" + id))); QNetworkReply* reply = this->manager.get(QNetworkRequest(QUrl("https://youvideo.nonamesoft.xyz/youvideo/video/" + id)));
QEventLoop loop(this);
QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
loop.exec();
if (reply->error() != QNetworkReply::NoError) if (reply->error() != QNetworkReply::NoError)
{ {
qDebug() << "Player::loadVideo(): Video " << id << " doesn't exist!\n"; qDebug() << "Player::loadVideo(): Video " << id << " doesn't exist!\n";
@@ -73,18 +78,22 @@ void Player::loadVideo(QString id)
return; return;
} }
qDebug() << "Player::fetchMetadata(): Yippie! Got video " << id << "\n"; const QJsonDocument data = QJsonDocument::fromJson(reply->readAll());
this->player.setSource(QUrl("https://youvideo.nonamesoft.xyz/youvideo/api/" + id)); this->player.setSource(QUrl("https://youvideo.nonamesoft.xyz/youvideo/api/videofile/with_extension/" + id + data ["extension"].toString()));
// Signals will be sent by shit sent from player emit this->hasVideoChanged();
emit this->loadingChanged();
this->m_failed = false; this->m_failed = false;
emit this->failedChanged(); emit this->failedChanged();
qDebug() << "Player::loadVideo(): Loaded video https://youvideo.nonamesoft.xyz/youvideo/api/videofile/with_extension/" + id + data ["extension"].toString();
delete reply; delete reply;
} }
void Player::unloadVideo() { void Player::unloadVideo() {
qDebug("Player::unloadVideo(): Video unloaded");
this->player.setSource(QUrl("")); this->player.setSource(QUrl(""));
this->player.stop(); this->player.stop();
this->m_failed = false; this->m_failed = false;
@@ -97,16 +106,18 @@ void Player::unloadVideo() {
void Player::play() void Player::play()
{ {
if (!this->hasVideo() || !this->loading()) qDebug() << "Player::play(): Can't play video?" << this->hasVideo() << this->loading();
if (!this->hasVideo() || this->loading())
{ {
return; return;
} }
this->player.play(); this->player.play();
} }
void Player::pause() void Player::pause()
{ {
if (!this->hasVideo() || !this->loading()) qDebug() << "Player::pause(): Can't pause video?" << (!this->hasVideo() || this->loading());
if (!this->hasVideo() || this->loading())
{ {
return; return;
} }
@@ -115,7 +126,8 @@ void Player::pause()
void Player::stop() void Player::stop()
{ {
if (!this->hasVideo() || !this->loading()) qDebug() << "Player::stop(): Can't stop video?" << (!this->hasVideo() || this->loading());
if (!this->hasVideo() || this->loading())
{ {
return; return;
} }