Read duration, samplerate and bit depth from stream url replies
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user