Read duration, samplerate and bit depth from stream url replies
This commit is contained in:
parent
f12b82b5ce
commit
15721da46e
|
@ -321,6 +321,18 @@ void Player::HandleLoadResult(const UrlHandler::LoadResult &result) {
|
|||
update = true;
|
||||
}
|
||||
|
||||
// If there was no samplerate info in song's metadata, use the one provided by URL handler, if there is one.
|
||||
if (song.samplerate() <= 0 && result.samplerate_ > 0) {
|
||||
song.set_samplerate(result.samplerate_);
|
||||
update = true;
|
||||
}
|
||||
|
||||
// If there was no bit depth info in song's metadata, use the one provided by URL handler, if there is one.
|
||||
if (song.bitdepth() <= 0 && result.bit_depth_ > 0) {
|
||||
song.set_bitdepth(result.bit_depth_);
|
||||
update = true;
|
||||
}
|
||||
|
||||
// If there was no length info in song's metadata, use the one provided by URL handler, if there is one.
|
||||
if (song.length_nanosec() <= 0 && result.length_nanosec_ != -1) {
|
||||
song.set_length_nanosec(result.length_nanosec_);
|
||||
|
|
|
@ -28,6 +28,15 @@
|
|||
#include "song.h"
|
||||
#include "urlhandler.h"
|
||||
|
||||
UrlHandler::LoadResult::LoadResult(const QUrl &original_url, Type type, const QUrl &media_url, const Song::FileType &filetype, const qint64 length_nanosec, const QString error) : original_url_(original_url), type_(type), media_url_(media_url), filetype_(filetype), length_nanosec_(length_nanosec), error_(error) {}
|
||||
UrlHandler::LoadResult::LoadResult(const QUrl &original_url, const Type type, const QUrl &media_url, const Song::FileType filetype, const int samplerate, const int bit_depth, const qint64 length_nanosec, const QString error) :
|
||||
original_url_(original_url),
|
||||
type_(type),
|
||||
media_url_(media_url),
|
||||
filetype_(filetype),
|
||||
samplerate_(samplerate),
|
||||
bit_depth_(bit_depth),
|
||||
length_nanosec_(length_nanosec),
|
||||
error_(error)
|
||||
{}
|
||||
|
||||
UrlHandler::UrlHandler(QObject *parent) : QObject(parent) {}
|
||||
|
|
|
@ -57,7 +57,7 @@ class UrlHandler : public QObject {
|
|||
Error,
|
||||
};
|
||||
|
||||
LoadResult(const QUrl &original_url = QUrl(), Type type = NoMoreTracks, const QUrl &media_url = QUrl(), const Song::FileType &filetype = Song::FileType_Stream, const qint64 length_nanosec_ = -1, const QString error = QString());
|
||||
LoadResult(const QUrl &original_url = QUrl(), const Type type = NoMoreTracks, const QUrl &media_url = QUrl(), const Song::FileType filetype = Song::FileType_Stream, const int samplerate = -1, const int bitdepth = -1, const qint64 length_nanosec_ = -1, const QString error = QString());
|
||||
|
||||
// The url that the playlist item has in Url().
|
||||
// Might be something unplayable like lastfm://...
|
||||
|
@ -71,7 +71,13 @@ class UrlHandler : public QObject {
|
|||
// The type of the stream
|
||||
Song::FileType filetype_;
|
||||
|
||||
// Track length, if we are able to get it only now
|
||||
// Track sample rate
|
||||
int samplerate_;
|
||||
|
||||
// Track bit depth
|
||||
int bit_depth_;
|
||||
|
||||
// Track length
|
||||
qint64 length_nanosec_;
|
||||
|
||||
// Error message, if any
|
||||
|
|
|
@ -77,7 +77,7 @@ class InternetService : public QObject {
|
|||
signals:
|
||||
void Login();
|
||||
void Logout();
|
||||
void Login(const QString &username, const QString &password, const QString &token);
|
||||
void Login(const QString &api_token, const QString &username, const QString &password);
|
||||
void Login(const QString &hostname, const int, const QString &username, const QString &password);
|
||||
void LoginSuccess();
|
||||
void LoginFailure(const QString &failure_reason);
|
||||
|
@ -121,7 +121,7 @@ class InternetService : public QObject {
|
|||
void RemoveAlbums(const SongList& songs);
|
||||
void RemoveSongs(const SongList& songs);
|
||||
|
||||
void StreamURLFinished(const QUrl &original_url, const QUrl &stream_url, const Song::FileType &filetype, const QString &error = QString());
|
||||
void StreamURLFinished(const QUrl &original_url, const QUrl &stream_url, const Song::FileType filetype, const int samplerate, const int bit_depth, const qint64 duration, QString error = QString());
|
||||
|
||||
protected:
|
||||
Application *app_;
|
||||
|
|
|
@ -605,7 +605,7 @@ void QobuzService::SearchResultsReceived(const int id, const SongList &songs, co
|
|||
void QobuzService::GetStreamURL(const QUrl &url) {
|
||||
|
||||
if (app_id().isEmpty() || app_secret().isEmpty()) { // Don't check for login here, because we allow automatic login.
|
||||
emit StreamURLFinished(url, url, Song::FileType_Stream, tr("Missing Qobuz app ID or secret."));
|
||||
emit StreamURLFinished(url, url, Song::FileType_Stream, -1, -1, -1, tr("Missing Qobuz app ID or secret."));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -613,21 +613,21 @@ void QobuzService::GetStreamURL(const QUrl &url) {
|
|||
stream_url_requests_ << stream_url_req;
|
||||
|
||||
connect(stream_url_req, SIGNAL(TryLogin()), this, SLOT(TryLogin()));
|
||||
connect(stream_url_req, SIGNAL(StreamURLFinished(const QUrl&, const QUrl&, const Song::FileType, QString)), this, SLOT(HandleStreamURLFinished(const QUrl&, const QUrl&, const Song::FileType&, QString)));
|
||||
connect(stream_url_req, SIGNAL(StreamURLFinished(const QUrl&, const QUrl&, const Song::FileType, const int, const int, const qint64, QString)), this, SLOT(HandleStreamURLFinished(const QUrl&, const QUrl&, const Song::FileType, const int, const int, const qint64, QString)));
|
||||
connect(this, SIGNAL(LoginComplete(const bool, QString)), stream_url_req, SLOT(LoginComplete(const bool, QString)));
|
||||
|
||||
stream_url_req->Process();
|
||||
|
||||
}
|
||||
|
||||
void QobuzService::HandleStreamURLFinished(const QUrl &original_url, const QUrl &stream_url, const Song::FileType filetype, QString error) {
|
||||
void QobuzService::HandleStreamURLFinished(const QUrl &original_url, const QUrl &media_url, const Song::FileType filetype, const int samplerate, const int bit_depth, const qint64 duration, QString error) {
|
||||
|
||||
QobuzStreamURLRequest *stream_url_req = qobject_cast<QobuzStreamURLRequest*>(sender());
|
||||
if (!stream_url_req || !stream_url_requests_.contains(stream_url_req)) return;
|
||||
stream_url_req->deleteLater();
|
||||
stream_url_requests_.removeAll(stream_url_req);
|
||||
|
||||
emit StreamURLFinished(original_url, stream_url, filetype, error);
|
||||
emit StreamURLFinished(original_url, media_url, filetype, samplerate, bit_depth, duration, error);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -140,7 +140,7 @@ class QobuzService : public InternetService {
|
|||
void ArtistsUpdateProgressReceived(const int id, const int progress);
|
||||
void AlbumsUpdateProgressReceived(const int id, const int progress);
|
||||
void SongsUpdateProgressReceived(const int id, const int progress);
|
||||
void HandleStreamURLFinished(const QUrl &original_url, const QUrl &stream_url, const Song::FileType filetype, QString error = QString());
|
||||
void HandleStreamURLFinished(const QUrl &original_url, const QUrl &media_url, const Song::FileType filetype, const int samplerate, const int bit_depth, const qint64 duration, QString error);
|
||||
|
||||
private:
|
||||
typedef QPair<QString, QString> Param;
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "core/logging.h"
|
||||
#include "core/network.h"
|
||||
#include "core/song.h"
|
||||
#include "core/timeconstants.h"
|
||||
#include "settings/qobuzsettingspage.h"
|
||||
#include "qobuzservice.h"
|
||||
#include "qobuzbaserequest.h"
|
||||
|
@ -66,7 +67,7 @@ void QobuzStreamURLRequest::LoginComplete(bool success, QString error) {
|
|||
need_login_ = false;
|
||||
|
||||
if (!success) {
|
||||
emit StreamURLFinished(original_url_, original_url_, Song::FileType_Stream, error);
|
||||
emit StreamURLFinished(original_url_, original_url_, Song::FileType_Stream, -1, -1, -1, error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -77,7 +78,7 @@ void QobuzStreamURLRequest::LoginComplete(bool success, QString error) {
|
|||
void QobuzStreamURLRequest::Process() {
|
||||
|
||||
if (app_id().isEmpty() || app_secret().isEmpty()) {
|
||||
emit StreamURLFinished(original_url_, original_url_, Song::FileType_Stream, tr("Missing Qobuz app ID or secret."));
|
||||
emit StreamURLFinished(original_url_, original_url_, Song::FileType_Stream, -1, -1, -1, tr("Missing Qobuz app ID or secret."));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -96,7 +97,7 @@ void QobuzStreamURLRequest::Cancel() {
|
|||
reply_->abort();
|
||||
}
|
||||
else {
|
||||
emit StreamURLFinished(original_url_, original_url_, Song::FileType_Stream, tr("Cancelled."));
|
||||
emit StreamURLFinished(original_url_, original_url_, Song::FileType_Stream, -1, -1, -1, tr("Cancelled."));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -158,33 +159,33 @@ void QobuzStreamURLRequest::StreamURLReceived() {
|
|||
need_login_ = true;
|
||||
return;
|
||||
}
|
||||
emit StreamURLFinished(original_url_, original_url_, Song::FileType_Stream, error);
|
||||
emit StreamURLFinished(original_url_, original_url_, Song::FileType_Stream, -1, -1, -1, error);
|
||||
return;
|
||||
}
|
||||
reply_ = nullptr;
|
||||
|
||||
QJsonObject json_obj = ExtractJsonObj(data, error);
|
||||
if (json_obj.isEmpty()) {
|
||||
emit StreamURLFinished(original_url_, original_url_, Song::FileType_Stream, error);
|
||||
emit StreamURLFinished(original_url_, original_url_, Song::FileType_Stream, -1, -1, -1, error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!json_obj.contains("track_id")) {
|
||||
error = Error("Invalid Json reply, stream url is missing track_id.", json_obj);
|
||||
emit StreamURLFinished(original_url_, original_url_, Song::FileType_Stream, error);
|
||||
emit StreamURLFinished(original_url_, original_url_, Song::FileType_Stream, -1, -1, -1, error);
|
||||
return;
|
||||
}
|
||||
|
||||
int track_id = json_obj["track_id"].toInt();
|
||||
if (track_id != song_id_) {
|
||||
error = Error("Incorrect track ID returned.", json_obj);
|
||||
emit StreamURLFinished(original_url_, original_url_, Song::FileType_Stream, error);
|
||||
emit StreamURLFinished(original_url_, original_url_, Song::FileType_Stream, -1, -1, -1, error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!json_obj.contains("mime_type") || !json_obj.contains("url")) {
|
||||
error = Error("Invalid Json reply, stream url is missing url or mime_type.", json_obj);
|
||||
emit StreamURLFinished(original_url_, original_url_, Song::FileType_Stream, error);
|
||||
emit StreamURLFinished(original_url_, original_url_, Song::FileType_Stream, -1, -1, -1, error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -204,10 +205,23 @@ void QobuzStreamURLRequest::StreamURLReceived() {
|
|||
|
||||
if (!url.isValid()) {
|
||||
error = Error("Returned stream url is invalid.", json_obj);
|
||||
emit StreamURLFinished(original_url_, original_url_, filetype, error);
|
||||
emit StreamURLFinished(original_url_, original_url_, filetype, -1, -1, -1, error);
|
||||
return;
|
||||
}
|
||||
|
||||
emit StreamURLFinished(original_url_, url, filetype);
|
||||
qint64 duration = -1;
|
||||
if (json_obj.contains("duration")) {
|
||||
duration = json_obj["duration"].toDouble() * kNsecPerSec;
|
||||
}
|
||||
int samplerate = -1;
|
||||
if (json_obj.contains("sampling_rate")) {
|
||||
samplerate = json_obj["sampling_rate"].toDouble() * 1000;
|
||||
}
|
||||
int bit_depth = -1;
|
||||
if (json_obj.contains("bit_depth")) {
|
||||
bit_depth = json_obj["bit_depth"].toDouble();
|
||||
}
|
||||
|
||||
emit StreamURLFinished(original_url_, url, filetype, samplerate, bit_depth, duration);
|
||||
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ class QobuzStreamURLRequest : public QobuzBaseRequest {
|
|||
|
||||
signals:
|
||||
void TryLogin();
|
||||
void StreamURLFinished(const QUrl &original_url, const QUrl &stream_url, const Song::FileType filetype, QString error = QString());
|
||||
void StreamURLFinished(const QUrl &original_url, const QUrl &stream_url, const Song::FileType filetype, const int samplerate, const int bit_depth, const qint64 duration, QString error = QString());
|
||||
|
||||
private slots:
|
||||
void LoginComplete(bool success, QString error = QString());
|
||||
|
|
|
@ -36,7 +36,7 @@ QobuzUrlHandler::QobuzUrlHandler(Application *app, QobuzService *service) :
|
|||
task_id_(-1)
|
||||
{
|
||||
|
||||
connect(service, SIGNAL(StreamURLFinished(QUrl, QUrl, Song::FileType, QString)), this, SLOT(GetStreamURLFinished(QUrl, QUrl, Song::FileType, QString)));
|
||||
connect(service, SIGNAL(StreamURLFinished(const QUrl&, const QUrl&, const Song::FileType, const int, const int, const qint64, QString)), this, SLOT(GetStreamURLFinished(const QUrl&, const QUrl&, const Song::FileType, const int, const int, const qint64, QString)));
|
||||
|
||||
}
|
||||
|
||||
|
@ -51,14 +51,14 @@ UrlHandler::LoadResult QobuzUrlHandler::StartLoading(const QUrl &url) {
|
|||
|
||||
}
|
||||
|
||||
void QobuzUrlHandler::GetStreamURLFinished(QUrl original_url, QUrl url, Song::FileType filetype, QString error) {
|
||||
void QobuzUrlHandler::GetStreamURLFinished(const QUrl &original_url, const QUrl &media_url, const Song::FileType filetype, const int samplerate, const int bit_depth, const qint64 duration, QString error) {
|
||||
|
||||
if (task_id_ == -1) return;
|
||||
CancelTask();
|
||||
if (error.isEmpty())
|
||||
emit AsyncLoadComplete(LoadResult(original_url, LoadResult::TrackAvailable, url, filetype));
|
||||
emit AsyncLoadComplete(LoadResult(original_url, LoadResult::TrackAvailable, media_url, filetype, samplerate, bit_depth, duration));
|
||||
else
|
||||
emit AsyncLoadComplete(LoadResult(original_url, LoadResult::Error, url, filetype, -1, error));
|
||||
emit AsyncLoadComplete(LoadResult(original_url, LoadResult::Error, media_url, filetype, -1, -1, -1, error));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ class QobuzUrlHandler : public UrlHandler {
|
|||
void CancelTask();
|
||||
|
||||
private slots:
|
||||
void GetStreamURLFinished(QUrl original_url, QUrl url, Song::FileType filetype, QString error = QString());
|
||||
void GetStreamURLFinished(const QUrl &original_url, const QUrl &media_url, const Song::FileType filetype, const int samplerate, const int bit_depth, const qint64 duration, QString error = QString());
|
||||
|
||||
private:
|
||||
Application *app_;
|
||||
|
|
|
@ -32,11 +32,11 @@ SubsonicUrlHandler::SubsonicUrlHandler(Application *app, SubsonicService *servic
|
|||
UrlHandler::LoadResult SubsonicUrlHandler::StartLoading(const QUrl &url) {
|
||||
|
||||
if (!server_url().isValid()) {
|
||||
return LoadResult(url, LoadResult::Error, url, Song::FileType_Stream, -1, tr("Subsonic server URL is invalid."));
|
||||
return LoadResult(url, LoadResult::Error, url, Song::FileType_Stream, -1, -1, -1, tr("Subsonic server URL is invalid."));
|
||||
}
|
||||
|
||||
if (username().isEmpty() || password().isEmpty()) {
|
||||
return LoadResult(url, LoadResult::Error, url, Song::FileType_Stream, -1, tr("Missing Subsonic username or password."));
|
||||
return LoadResult(url, LoadResult::Error, url, Song::FileType_Stream, -1, -1, -1, tr("Missing Subsonic username or password."));
|
||||
}
|
||||
|
||||
ParamList params = ParamList() << Param("c", service_->client_name())
|
||||
|
|
|
@ -866,11 +866,11 @@ void TidalService::GetStreamURL(const QUrl &url) {
|
|||
|
||||
if (!authenticated()) {
|
||||
if (oauth_) {
|
||||
emit StreamURLFinished(url, url, Song::FileType_Stream, tr("Not authenticated with Tidal."));
|
||||
emit StreamURLFinished(url, url, Song::FileType_Stream, -1, -1, -1, tr("Not authenticated with Tidal."));
|
||||
return;
|
||||
}
|
||||
else if (api_token_.isEmpty() || username_.isEmpty() || password_.isEmpty()) {
|
||||
emit StreamURLFinished(url, url, Song::FileType_Stream, tr("Missing Tidal API token, username or passord."));
|
||||
emit StreamURLFinished(url, url, Song::FileType_Stream, -1, -1, -1, tr("Missing Tidal API token, username or passord."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -879,21 +879,21 @@ void TidalService::GetStreamURL(const QUrl &url) {
|
|||
stream_url_requests_ << stream_url_req;
|
||||
|
||||
connect(stream_url_req, SIGNAL(TryLogin()), this, SLOT(TryLogin()));
|
||||
connect(stream_url_req, SIGNAL(StreamURLFinished(const QUrl&, const QUrl&, const Song::FileType, const QString&)), this, SLOT(HandleStreamURLFinished(const QUrl&, const QUrl&, const Song::FileType, QString)));
|
||||
connect(stream_url_req, SIGNAL(StreamURLFinished(const QUrl&, const QUrl&, const Song::FileType, const int, const int, const qint64, QString)), this, SLOT(HandleStreamURLFinished(const QUrl&, const QUrl&, const Song::FileType, const int, const int, const qint64, QString)));
|
||||
connect(this, SIGNAL(LoginComplete(const bool, const QString&)), stream_url_req, SLOT(LoginComplete(const bool, QString)));
|
||||
|
||||
stream_url_req->Process();
|
||||
|
||||
}
|
||||
|
||||
void TidalService::HandleStreamURLFinished(const QUrl &original_url, const QUrl &stream_url, const Song::FileType filetype, QString error) {
|
||||
void TidalService::HandleStreamURLFinished(const QUrl &original_url, const QUrl &stream_url, const Song::FileType filetype, const int samplerate, const int bit_depth, const qint64 duration, QString error) {
|
||||
|
||||
TidalStreamURLRequest *stream_url_req = qobject_cast<TidalStreamURLRequest*>(sender());
|
||||
if (!stream_url_req || !stream_url_requests_.contains(stream_url_req)) return;
|
||||
stream_url_req->deleteLater();
|
||||
stream_url_requests_.removeAll(stream_url_req);
|
||||
|
||||
emit StreamURLFinished(original_url, stream_url, filetype, error);
|
||||
emit StreamURLFinished(original_url, stream_url, filetype, samplerate, bit_depth, duration, error);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -150,7 +150,7 @@ class TidalService : public InternetService {
|
|||
void ArtistsUpdateProgressReceived(const int id, const int progress);
|
||||
void AlbumsUpdateProgressReceived(const int id, const int progress);
|
||||
void SongsUpdateProgressReceived(const int id, const int progress);
|
||||
void HandleStreamURLFinished(const QUrl &original_url, const QUrl &stream_url, const Song::FileType filetype, QString error = QString());
|
||||
void HandleStreamURLFinished(const QUrl &original_url, const QUrl &stream_url, const Song::FileType filetype, const int samplerate, const int bit_depth, const qint64 duration, QString error = QString());
|
||||
|
||||
private:
|
||||
typedef QPair<QString, QString> Param;
|
||||
|
|
|
@ -65,7 +65,7 @@ void TidalStreamURLRequest::LoginComplete(const bool success, QString error) {
|
|||
need_login_ = false;
|
||||
|
||||
if (!success) {
|
||||
emit StreamURLFinished(original_url_, original_url_, Song::FileType_Stream, error);
|
||||
emit StreamURLFinished(original_url_, original_url_, Song::FileType_Stream, -1, -1, -1, error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -77,11 +77,11 @@ void TidalStreamURLRequest::Process() {
|
|||
|
||||
if (!authenticated()) {
|
||||
if (oauth()) {
|
||||
emit StreamURLFinished(original_url_, original_url_, Song::FileType_Stream, tr("Not authenticated with Tidal."));
|
||||
emit StreamURLFinished(original_url_, original_url_, Song::FileType_Stream, -1, -1, -1, tr("Not authenticated with Tidal."));
|
||||
return;
|
||||
}
|
||||
else if (api_token().isEmpty() || username().isEmpty() || password().isEmpty()) {
|
||||
emit StreamURLFinished(original_url_, original_url_, Song::FileType_Stream, tr("Missing Tidal API token, username or passord."));
|
||||
emit StreamURLFinished(original_url_, original_url_, Song::FileType_Stream, -1, -1, -1, tr("Missing Tidal API token, username or passord."));
|
||||
return;
|
||||
}
|
||||
need_login_ = true;
|
||||
|
@ -99,7 +99,7 @@ void TidalStreamURLRequest::Cancel() {
|
|||
reply_->abort();
|
||||
}
|
||||
else {
|
||||
emit StreamURLFinished(original_url_, original_url_, Song::FileType_Stream, tr("Cancelled."));
|
||||
emit StreamURLFinished(original_url_, original_url_, Song::FileType_Stream, -1, -1, -1, tr("Cancelled."));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ void TidalStreamURLRequest::StreamURLReceived() {
|
|||
need_login_ = true;
|
||||
return;
|
||||
}
|
||||
emit StreamURLFinished(original_url_, original_url_, Song::FileType_Stream, error);
|
||||
emit StreamURLFinished(original_url_, original_url_, Song::FileType_Stream, -1, -1, -1, error);
|
||||
return;
|
||||
}
|
||||
reply_ = nullptr;
|
||||
|
@ -165,19 +165,19 @@ void TidalStreamURLRequest::StreamURLReceived() {
|
|||
|
||||
QJsonObject json_obj = ExtractJsonObj(data, error);
|
||||
if (json_obj.isEmpty()) {
|
||||
emit StreamURLFinished(original_url_, original_url_, Song::FileType_Stream, error);
|
||||
emit StreamURLFinished(original_url_, original_url_, Song::FileType_Stream, -1, -1, -1, error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!json_obj.contains("trackId")) {
|
||||
error = Error("Invalid Json reply, stream missing trackId.", json_obj);
|
||||
emit StreamURLFinished(original_url_, original_url_, Song::FileType_Stream, error);
|
||||
emit StreamURLFinished(original_url_, original_url_, Song::FileType_Stream, -1, -1, -1, error);
|
||||
return;
|
||||
}
|
||||
int track_id(json_obj["trackId"].toInt());
|
||||
if (track_id != song_id_) {
|
||||
error = Error("Incorrect track ID returned.", json_obj);
|
||||
emit StreamURLFinished(original_url_, original_url_, Song::FileType_Stream, error);
|
||||
emit StreamURLFinished(original_url_, original_url_, Song::FileType_Stream, -1, -1, -1, error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -210,7 +210,7 @@ void TidalStreamURLRequest::StreamURLReceived() {
|
|||
QString filename = "tidal-" + QString::number(song_id_) + ".xml";
|
||||
if (!QDir().mkpath(filepath)) {
|
||||
error = Error(QString("Failed to create directory %1.").arg(filepath), json_obj);
|
||||
emit StreamURLFinished(original_url_, original_url_, Song::FileType_Stream, error);
|
||||
emit StreamURLFinished(original_url_, original_url_, Song::FileType_Stream, -1, -1, -1, error);
|
||||
return;
|
||||
}
|
||||
QUrl url("file://" + filepath + "/" + filename);
|
||||
|
@ -219,7 +219,7 @@ void TidalStreamURLRequest::StreamURLReceived() {
|
|||
file.remove();
|
||||
if (!file.open(QIODevice::WriteOnly)) {
|
||||
error = Error(QString("Failed to open file %1 for writing.").arg(url.toLocalFile()), json_obj);
|
||||
emit StreamURLFinished(original_url_, original_url_, Song::FileType_Stream, error);
|
||||
emit StreamURLFinished(original_url_, original_url_, Song::FileType_Stream, -1, -1, -1, error);
|
||||
return;
|
||||
}
|
||||
file.write(data_manifest);
|
||||
|
@ -233,13 +233,13 @@ void TidalStreamURLRequest::StreamURLReceived() {
|
|||
|
||||
json_obj = ExtractJsonObj(data_manifest, error);
|
||||
if (json_obj.isEmpty()) {
|
||||
emit StreamURLFinished(original_url_, original_url_, Song::FileType_Stream, error);
|
||||
emit StreamURLFinished(original_url_, original_url_, Song::FileType_Stream, -1, -1, -1, error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!json_obj.contains("mimeType")) {
|
||||
error = Error("Invalid Json reply, stream url reply manifest is missing mimeType.", json_obj);
|
||||
emit StreamURLFinished(original_url_, original_url_, Song::FileType_Stream, error);
|
||||
emit StreamURLFinished(original_url_, original_url_, Song::FileType_Stream, -1, -1, -1, error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -261,7 +261,7 @@ void TidalStreamURLRequest::StreamURLReceived() {
|
|||
QJsonValue json_urls = json_obj["urls"];
|
||||
if (!json_urls.isArray()) {
|
||||
error = Error("Invalid Json reply, urls is not an array.", json_urls);
|
||||
emit StreamURLFinished(original_url_, original_url_, Song::FileType_Stream, error);
|
||||
emit StreamURLFinished(original_url_, original_url_, Song::FileType_Stream, -1, -1, -1, error);
|
||||
return;
|
||||
}
|
||||
QJsonArray json_array_urls = json_urls.toArray();
|
||||
|
@ -276,10 +276,10 @@ void TidalStreamURLRequest::StreamURLReceived() {
|
|||
|
||||
if (urls.isEmpty()) {
|
||||
error = Error("Missing stream urls.", json_obj);
|
||||
emit StreamURLFinished(original_url_, original_url_, filetype, error);
|
||||
emit StreamURLFinished(original_url_, original_url_, filetype, -1, -1, -1, error);
|
||||
return;
|
||||
}
|
||||
|
||||
emit StreamURLFinished(original_url_, urls.first(), filetype);
|
||||
emit StreamURLFinished(original_url_, urls.first(), filetype, -1, -1, -1);
|
||||
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ class TidalStreamURLRequest : public TidalBaseRequest {
|
|||
|
||||
signals:
|
||||
void TryLogin();
|
||||
void StreamURLFinished(const QUrl &original_url, const QUrl &stream_url, const Song::FileType filetype, QString error = QString());
|
||||
void StreamURLFinished(const QUrl &original_url, const QUrl &stream_url, const Song::FileType filetype, const int samplerate, const int bit_depth, const qint64 duration, QString error = QString());
|
||||
|
||||
private slots:
|
||||
void LoginComplete(const bool success, QString error = QString());
|
||||
|
|
|
@ -36,7 +36,7 @@ TidalUrlHandler::TidalUrlHandler(Application *app, TidalService *service) :
|
|||
task_id_(-1)
|
||||
{
|
||||
|
||||
connect(service, SIGNAL(StreamURLFinished(QUrl, QUrl, Song::FileType, QString)), this, SLOT(GetStreamURLFinished(QUrl, QUrl, Song::FileType, QString)));
|
||||
connect(service, SIGNAL(StreamURLFinished(const QUrl&, const QUrl&, const Song::FileType, const int, const int, const qint64, QString)), this, SLOT(GetStreamURLFinished(const QUrl&, const QUrl&, const Song::FileType, const int, const int, const qint64, QString)));
|
||||
|
||||
}
|
||||
|
||||
|
@ -51,14 +51,14 @@ UrlHandler::LoadResult TidalUrlHandler::StartLoading(const QUrl &url) {
|
|||
|
||||
}
|
||||
|
||||
void TidalUrlHandler::GetStreamURLFinished(QUrl original_url, QUrl url, Song::FileType filetype, QString error) {
|
||||
void TidalUrlHandler::GetStreamURLFinished(const QUrl &original_url, const QUrl &media_url, const Song::FileType filetype, const int samplerate, const int bit_depth, const qint64 duration, QString error) {
|
||||
|
||||
if (task_id_ == -1) return;
|
||||
CancelTask();
|
||||
if (error.isEmpty())
|
||||
emit AsyncLoadComplete(LoadResult(original_url, LoadResult::TrackAvailable, url, filetype));
|
||||
emit AsyncLoadComplete(LoadResult(original_url, LoadResult::TrackAvailable, media_url, filetype, samplerate, bit_depth, duration));
|
||||
else
|
||||
emit AsyncLoadComplete(LoadResult(original_url, LoadResult::Error, url, filetype, -1, error));
|
||||
emit AsyncLoadComplete(LoadResult(original_url, LoadResult::Error, media_url, filetype, -1, -1, -1, error));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ class TidalUrlHandler : public UrlHandler {
|
|||
void CancelTask();
|
||||
|
||||
private slots:
|
||||
void GetStreamURLFinished(QUrl original_url, QUrl url, Song::FileType filetype, QString error = QString());
|
||||
void GetStreamURLFinished(const QUrl &original_url, const QUrl &media_url, const Song::FileType filetype, const int samplerate, const int bit_depth, const qint64 duration, QString error = QString());
|
||||
|
||||
private:
|
||||
Application *app_;
|
||||
|
|
Loading…
Reference in New Issue