Fix deezer url handler

This commit is contained in:
Jonas Kvinge 2018-10-30 23:18:25 +01:00
parent f456ca674d
commit 4993201b70
3 changed files with 13 additions and 5 deletions

View File

@ -768,14 +768,15 @@ Song DeezerService::ParseSong(const int album_id, const QString &album, const QS
}
void DeezerService::GetStreamURL(const QUrl &original_url) {
bool DeezerService::GetStreamURL(const QUrl &original_url) {
#ifdef HAVE_DZMEDIA
stream_request_url_ = original_url;
dzmedia_->GetStreamURL(original_url);
return true;
#else
stream_request_url_ = QUrl();
emit StreamURLReceived(original_url, original_url, Song::FileType_Stream);
return false;
#endif
}

View File

@ -76,7 +76,7 @@ class DeezerService : public InternetService {
const bool app_id() { return kAppID; }
const bool authenticated() { return !access_token_.isEmpty(); }
void GetStreamURL(const QUrl &url);
bool GetStreamURL(const QUrl &url);
signals:
void Login();

View File

@ -43,8 +43,15 @@ UrlHandler::LoadResult DeezerUrlHandler::StartLoading(const QUrl &url) {
if (task_id_ != -1) return ret;
last_original_url_ = url;
task_id_ = app_->task_manager()->StartTask(QString("Loading %1 stream...").arg(url.scheme()));
service_->GetStreamURL(url);
ret.type_ = LoadResult::WillLoadAsynchronously;
bool wait_for_url = service_->GetStreamURL(url);
if (wait_for_url) {
ret.type_ = LoadResult::WillLoadAsynchronously;
}
else {
CancelTask();
ret.type_ = LoadResult::TrackAvailable;
ret.media_url_ = url;
}
return ret;
}