1
0
mirror of https://github.com/clementine-player/Clementine synced 2024-12-22 07:54:18 +01:00

Fix compilation on older Qt, use Player::SongChangeRequestProcessed() signal to handle station play count

This commit is contained in:
Fabio Bas 2021-03-28 15:23:34 +02:00 committed by John Maguire
parent cd561af516
commit 91e1e5880d
2 changed files with 20 additions and 10 deletions

View File

@ -146,6 +146,8 @@ RadioBrowserService::RadioBrowserService(Application* app,
app_->player()->RegisterUrlHandler(url_handler_);
app_->global_search()->AddProvider(
new RadioBrowserSearchProvider(app_, this, this));
connect(app_->player(), SIGNAL(SongChangeRequestProcessed(QUrl, bool)), this,
SLOT(SongChangeRequestProcessed(QUrl, bool)));
}
QStandardItem* RadioBrowserService::CreateRootItem() {
@ -422,8 +424,11 @@ void RadioBrowserService::ResolveStationUrl(const QUrl& original_url) {
StreamList list;
QJsonArray contents = document.array();
QJsonValue item = contents.first();
if (item.isUndefined()) return;
QJsonObject item = contents.first().toObject();
if (item.isEmpty()) {
emit StationUrlResolved(original_url, QUrl());
return;
}
Song ret;
ret.set_valid(true);
@ -434,17 +439,21 @@ void RadioBrowserService::ResolveStationUrl(const QUrl& original_url) {
emit StreamMetadataFound(original_url, ret);
emit StationUrlResolved(original_url, ret.url());
// inform the server that we played the station
QString determinedUrl =
PlayClickUrl.arg(main_server_url_, original_url.path());
QUrl playUrl(determinedUrl);
QNetworkReply* playReply = network_->get(QNetworkRequest(playUrl));
connect(playReply, &QNetworkReply::finished,
[=] { playReply->deleteLater(); });
});
}
void RadioBrowserService::SongChangeRequestProcessed(const QUrl& url,
bool valid) {
if (!valid || url.scheme() != url_handler_->scheme()) return;
// inform the server that the station is playing
QString determinedUrl = PlayClickUrl.arg(main_server_url_, url.path());
QUrl playUrl(determinedUrl);
QNetworkReply* playReply = network_->get(QNetworkRequest(playUrl));
connect(playReply, &QNetworkReply::finished,
[=] { playReply->deleteLater(); });
}
void RadioBrowserService::AddToSavedRadio(bool checked) {
Q_UNUSED(checked);
QAction* action = qobject_cast<QAction*>(sender());

View File

@ -85,6 +85,7 @@ class RadioBrowserService : public InternetService {
public slots:
void ReloadSettings() override;
void SongChangeRequestProcessed(const QUrl& url, bool valid);
private slots:
void LazyPopulate(QStandardItem* item) override;