Add stream discoverer to gstreamer pipeline and continuous updating of bitrate
This commit is contained in:
@@ -1478,29 +1478,25 @@ void Playlist::StopAfter(int row) {
|
||||
|
||||
}
|
||||
|
||||
void Playlist::SetStreamMetadata(const QUrl &url, const Song &song) {
|
||||
void Playlist::SetStreamMetadata(const QUrl &url, const Song &song, const bool minor) {
|
||||
|
||||
if (!current_item()) return;
|
||||
if (current_item()->Url() != url) return;
|
||||
if (!current_item() || current_item()->Url() != url) return;
|
||||
|
||||
// Don't update the metadata if it's only a minor change from before
|
||||
if (
|
||||
current_item()->Metadata().filetype() == song.filetype() &&
|
||||
current_item()->Metadata().artist() == song.artist() &&
|
||||
current_item()->Metadata().title() == song.title() &&
|
||||
current_item()->Metadata().album() == song.album()
|
||||
) return;
|
||||
|
||||
// TODO: Update context & playlist if changed, but don't show popup.
|
||||
//(song.bitrate() <= 0 || current_item()->Metadata().bitrate() == song.bitrate())
|
||||
//(song.samplerate() <= 0 || current_item()->Metadata().samplerate() == song.samplerate())
|
||||
//(song.bitdepth() <= 0 || current_item()->Metadata().bitdepth() == song.bitdepth())
|
||||
|
||||
qLog(Debug) << "Setting metadata for" << url << "to" << song.artist() << song.title();
|
||||
//qLog(Debug) << "Setting temporary metadata for" << url;
|
||||
|
||||
current_item()->SetTemporaryMetadata(song);
|
||||
|
||||
InformOfCurrentSongChange();
|
||||
if (minor) {
|
||||
emit dataChanged(index(current_item_index_.row(), 0), index(current_item_index_.row(), ColumnCount - 1));
|
||||
// if the song is invalid, we won't play it - there's no point in informing anybody about the change
|
||||
const Song metadata(current_item_metadata());
|
||||
if (metadata.is_valid()) {
|
||||
emit SongMetadataChanged(metadata);
|
||||
}
|
||||
}
|
||||
else {
|
||||
InformOfCurrentSongChange();
|
||||
}
|
||||
|
||||
UpdateScrobblePoint();
|
||||
|
||||
@@ -1936,12 +1932,11 @@ bool Playlist::ApplyValidityOnCurrentSong(const QUrl &url, bool valid) {
|
||||
Song current_song = current->Metadata();
|
||||
|
||||
// If validity has changed, reload the item
|
||||
// FIXME: Why?
|
||||
// Removed this because it caused "Empty filename passed to function" errors when not using local filenames.
|
||||
// It also causes Context and Playing widget to reload the image and getting stuck in playing mode when the URL is broken.
|
||||
//if(!current_song.is_cdda() && current_song.url() == url && current_song.is_valid() != QFile::exists(current_song.url().toLocalFile())) {
|
||||
//ReloadItems(QList<int>() << current_row());
|
||||
//}
|
||||
if (current_song.source() == Song::Source_LocalFile || current_song.source() == Song::Source_Collection) {
|
||||
if (current_song.url() == url && current_song.url().isLocalFile() && current_song.is_valid() != QFile::exists(current_song.url().toLocalFile())) {
|
||||
ReloadItems(QList<int>() << current_row());
|
||||
}
|
||||
}
|
||||
|
||||
// Gray out the song if it's now broken; otherwise undo the gray color
|
||||
if (valid) {
|
||||
|
||||
@@ -281,7 +281,7 @@ class Playlist : public QAbstractListModel {
|
||||
void IgnoreSorting(bool value) { ignore_sorting_ = value; }
|
||||
|
||||
void ClearStreamMetadata();
|
||||
void SetStreamMetadata(const QUrl &url, const Song &song);
|
||||
void SetStreamMetadata(const QUrl &url, const Song &song, const bool minor);
|
||||
void ItemChanged(PlaylistItemPtr item);
|
||||
void UpdateItems(const SongList &songs);
|
||||
|
||||
@@ -298,10 +298,11 @@ class Playlist : public QAbstractListModel {
|
||||
// Removes items with given indices from the playlist. This operation is not undoable.
|
||||
void RemoveItemsWithoutUndo(const QList<int> &indices);
|
||||
|
||||
signals:
|
||||
signals:
|
||||
void RestoreFinished();
|
||||
void PlaylistLoaded();
|
||||
void CurrentSongChanged(const Song &metadata);
|
||||
void SongMetadataChanged(const Song &metadata);
|
||||
void EditingFinished(const QModelIndex &index);
|
||||
void PlayRequested(const QModelIndex &index);
|
||||
|
||||
@@ -314,7 +315,7 @@ signals:
|
||||
// Signals that the queue has changed, meaning that the remaining queued items should update their position.
|
||||
void QueueChanged();
|
||||
|
||||
private:
|
||||
private:
|
||||
void SetCurrentIsPaused(bool paused);
|
||||
int NextVirtualIndex(int i, bool ignore_repeat_track) const;
|
||||
int PreviousVirtualIndex(int i, bool ignore_repeat_track) const;
|
||||
@@ -346,7 +347,7 @@ private:
|
||||
void ItemsLoaded(QFuture<PlaylistItemList> future);
|
||||
void SongInsertVetoListenerDestroyed();
|
||||
|
||||
private:
|
||||
private:
|
||||
bool is_loading_;
|
||||
PlaylistFilter *proxy_;
|
||||
Queue *queue_;
|
||||
@@ -396,8 +397,4 @@ private:
|
||||
|
||||
};
|
||||
|
||||
// QDataStream& operator <<(QDataStream&, const Playlist*);
|
||||
// QDataStream& operator >>(QDataStream&, Playlist*&);
|
||||
|
||||
#endif // PLAYLIST_H
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ class PlaylistItem : public std::enable_shared_from_this<PlaylistItem> {
|
||||
void SetTemporaryMetadata(const Song &metadata);
|
||||
void ClearTemporaryMetadata();
|
||||
bool HasTemporaryMetadata() const { return temp_metadata_.is_valid(); }
|
||||
QUrl MediaUrl() const { return HasTemporaryMetadata() && temp_metadata_.is_valid() && temp_metadata_.url().isValid() ? temp_metadata_.url() : QUrl(); }
|
||||
QUrl StreamUrl() const { return HasTemporaryMetadata() && temp_metadata_.is_valid() && temp_metadata_.url().isValid() ? temp_metadata_.url() : QUrl(); }
|
||||
|
||||
// Background colors.
|
||||
void SetBackgroundColor(short priority, const QColor &color);
|
||||
|
||||
@@ -140,6 +140,7 @@ Playlist *PlaylistManager::AddPlaylist(int id, const QString &name, const QStrin
|
||||
ret->set_ui_path(ui_path);
|
||||
|
||||
connect(ret, SIGNAL(CurrentSongChanged(Song)), SIGNAL(CurrentSongChanged(Song)));
|
||||
connect(ret, SIGNAL(SongMetadataChanged(Song)), SIGNAL(SongMetadataChanged(Song)));
|
||||
connect(ret, SIGNAL(PlaylistChanged()), SLOT(OneOfPlaylistsChanged()));
|
||||
connect(ret, SIGNAL(PlaylistChanged()), SLOT(UpdateSummaryText()));
|
||||
connect(ret, SIGNAL(EditingFinished(QModelIndex)), SIGNAL(EditingFinished(QModelIndex)));
|
||||
|
||||
@@ -119,6 +119,7 @@ public slots:
|
||||
|
||||
// Forwarded from individual playlists
|
||||
void CurrentSongChanged(const Song& song);
|
||||
void SongMetadataChanged(const Song& song);
|
||||
|
||||
// Signals that one of manager's playlists has changed (new items, new ordering etc.) - the argument shows which.
|
||||
void PlaylistChanged(Playlist *playlist);
|
||||
|
||||
Reference in New Issue
Block a user