Use URL Handler for Tidal
This commit is contained in:
@@ -224,10 +224,26 @@ void Player::HandleLoadResult(const UrlHandler::LoadResult &result) {
|
||||
|
||||
qLog(Debug) << "URL handler for" << result.original_url_ << "returned" << result.media_url_;
|
||||
|
||||
Song song = item->Metadata();
|
||||
bool update(false);
|
||||
|
||||
// If there was no filetype in the song's metadata, use the one provided by URL handler, if there is one
|
||||
if (
|
||||
(item->Metadata().filetype() == Song::FileType_Unknown && result.filetype_ != Song::FileType_Unknown)
|
||||
||
|
||||
(item->Metadata().filetype() == Song::FileType_Stream && result.filetype_ != Song::FileType_Stream)
|
||||
)
|
||||
{
|
||||
song.set_filetype(result.filetype_);
|
||||
update = true;
|
||||
}
|
||||
// If there was no length info in song's metadata, use the one provided by URL handler, if there is one
|
||||
if (item->Metadata().length_nanosec() <= 0 && result.length_nanosec_ != -1) {
|
||||
if (item->Metadata().length_nanosec() <= 0 && result.length_nanosec_ != -1) {
|
||||
Song song = item->Metadata();
|
||||
song.set_length_nanosec(result.length_nanosec_);
|
||||
update = true;
|
||||
}
|
||||
if (update) {
|
||||
item->SetTemporaryMetadata(song);
|
||||
app_->playlist_manager()->active()->InformOfCurrentSongChange();
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
#include "urlhandler.h"
|
||||
|
||||
UrlHandler::LoadResult::LoadResult(const QUrl &original_url, Type type, const QUrl &media_url, qint64 length_nanosec) : original_url_(original_url), type_(type), media_url_(media_url), length_nanosec_(length_nanosec) {}
|
||||
UrlHandler::LoadResult::LoadResult(const QUrl &original_url, Type type, const QUrl &media_url, const Song::FileType &filetype, qint64 length_nanosec) : original_url_(original_url), type_(type), media_url_(media_url), filetype_(filetype), length_nanosec_(length_nanosec) {}
|
||||
|
||||
UrlHandler::UrlHandler(QObject *parent) : QObject(parent) {}
|
||||
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
#include <QUrl>
|
||||
#include <QIcon>
|
||||
|
||||
#include "song.h"
|
||||
|
||||
class UrlHandler : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
@@ -53,7 +55,7 @@ class UrlHandler : public QObject {
|
||||
TrackAvailable,
|
||||
};
|
||||
|
||||
LoadResult(const QUrl &original_url = QUrl(), Type type = NoMoreTracks, const QUrl &media_url = QUrl(), qint64 length_nanosec_ = -1);
|
||||
LoadResult(const QUrl &original_url = QUrl(), Type type = NoMoreTracks, const QUrl &media_url = QUrl(), const Song::FileType &filetype = Song::FileType_Stream, qint64 length_nanosec_ = -1);
|
||||
|
||||
// The url that the playlist item has in Url().
|
||||
// Might be something unplayable like lastfm://...
|
||||
@@ -64,6 +66,9 @@ class UrlHandler : public QObject {
|
||||
// The actual url to something that gstreamer can play.
|
||||
QUrl media_url_;
|
||||
|
||||
// The type of the stream
|
||||
Song::FileType filetype_;
|
||||
|
||||
// Track length, if we are able to get it only now
|
||||
qint64 length_nanosec_;
|
||||
};
|
||||
@@ -78,8 +83,9 @@ class UrlHandler : public QObject {
|
||||
virtual void TrackAboutToEnd() {};
|
||||
virtual void TrackSkipped() {};
|
||||
|
||||
signals:
|
||||
signals:
|
||||
void AsyncLoadComplete(const UrlHandler::LoadResult &result);
|
||||
|
||||
};
|
||||
|
||||
#endif // URLHANDLER_H
|
||||
|
||||
Reference in New Issue
Block a user