forked from ghostfox/qyouradio
plhabj workding
This commit is contained in:
28
player.cpp
28
player.cpp
@@ -65,7 +65,12 @@ void Player::loadVideo(QString id)
|
||||
{
|
||||
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)
|
||||
{
|
||||
qDebug() << "Player::loadVideo(): Video " << id << " doesn't exist!\n";
|
||||
@@ -73,18 +78,22 @@ void Player::loadVideo(QString id)
|
||||
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;
|
||||
emit this->failedChanged();
|
||||
|
||||
qDebug() << "Player::loadVideo(): Loaded video https://youvideo.nonamesoft.xyz/youvideo/api/videofile/with_extension/" + id + data ["extension"].toString();
|
||||
|
||||
delete reply;
|
||||
}
|
||||
|
||||
void Player::unloadVideo() {
|
||||
qDebug("Player::unloadVideo(): Video unloaded");
|
||||
this->player.setSource(QUrl(""));
|
||||
this->player.stop();
|
||||
this->m_failed = false;
|
||||
@@ -97,16 +106,18 @@ void Player::unloadVideo() {
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
this->player.play();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -115,7 +126,8 @@ void Player::pause()
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user