Make scrobbler handle streams
This commit is contained in:
@@ -510,6 +510,8 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, co
|
||||
connect(app_->player(), SIGNAL(VolumeChanged(int)), osd_, SLOT(VolumeChanged(int)));
|
||||
connect(app_->player(), SIGNAL(VolumeChanged(int)), ui_->volume, SLOT(setValue(int)));
|
||||
connect(app_->player(), SIGNAL(ForceShowOSD(Song, bool)), SLOT(ForceShowOSD(Song, bool)));
|
||||
connect(app_->player(), SIGNAL(SendNowPlaying()), SLOT(SendNowPlaying()));
|
||||
|
||||
connect(app_->playlist_manager(), SIGNAL(CurrentSongChanged(Song)), SLOT(SongChanged(Song)));
|
||||
connect(app_->playlist_manager(), SIGNAL(CurrentSongChanged(Song)), app_->player(), SLOT(CurrentMetadataChanged(Song)));
|
||||
connect(app_->playlist_manager(), SIGNAL(EditingFinished(QModelIndex)), SLOT(PlaylistEditFinished(QModelIndex)));
|
||||
@@ -854,15 +856,13 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSD *osd, co
|
||||
if (!options.contains_play_options()) {
|
||||
LoadPlaybackStatus();
|
||||
}
|
||||
if (app_->scrobbler()->IsEnabled() && !app_->scrobbler()->IsOffline()) app_->scrobbler()->Submit();
|
||||
|
||||
RefreshStyleSheet();
|
||||
|
||||
qLog(Debug) << "Started" << QThread::currentThread();
|
||||
initialised_ = true;
|
||||
|
||||
app_->scrobbler()->ConnectError();
|
||||
if (app_->scrobbler()->IsEnabled() && !app_->scrobbler()->IsOffline()) app_->scrobbler()->Submit();
|
||||
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow() {
|
||||
@@ -1101,10 +1101,18 @@ void MainWindow::MediaPlaying() {
|
||||
track_position_timer_->start();
|
||||
track_slider_timer_->start();
|
||||
UpdateTrackPosition();
|
||||
SendNowPlaying();
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::SendNowPlaying() {
|
||||
|
||||
PlaylistItemPtr item(app_->player()->GetCurrentItem());
|
||||
if (!item) return;
|
||||
|
||||
// Send now playing to scrobble services
|
||||
Playlist *playlist = app_->playlist_manager()->active();
|
||||
if (app_->scrobbler()->IsEnabled() && playlist && !playlist->nowplaying() && item->Metadata().is_metadata_good() && item->Metadata().length_nanosec() > 0) {
|
||||
if (app_->scrobbler()->IsEnabled() && playlist && !playlist->nowplaying() && item->Metadata().is_metadata_good()) {
|
||||
app_->scrobbler()->UpdateNowPlaying(item->Metadata());
|
||||
playlist->set_nowplaying(true);
|
||||
ui_->action_love->setEnabled(true);
|
||||
@@ -2039,7 +2047,7 @@ void MainWindow::CommandlineOptionsReceived(const CommandlineOptions &options) {
|
||||
if (!options.urls().empty()) {
|
||||
|
||||
#ifdef HAVE_TIDAL
|
||||
for (const QUrl url : options.urls()) {
|
||||
for (const QUrl &url : options.urls()) {
|
||||
if (url.scheme() == "tidal" && url.host() == "login") {
|
||||
emit AuthorisationUrlReceived(url);
|
||||
return;
|
||||
@@ -2671,7 +2679,7 @@ void MainWindow::LoveButtonVisibilityChanged(const bool value) {
|
||||
void MainWindow::SetToggleScrobblingIcon(const bool value) {
|
||||
|
||||
if (value) {
|
||||
if (app_->playlist_manager()->active()->scrobbled())
|
||||
if (app_->playlist_manager()->active() && app_->playlist_manager()->active()->scrobbled())
|
||||
ui_->action_toggle_scrobbling->setIcon(IconLoader::Load("scrobble", 22));
|
||||
else
|
||||
ui_->action_toggle_scrobbling->setIcon(IconLoader::Load("scrobble", 22)); // TODO: Create a faint version of the icon
|
||||
|
||||
@@ -258,6 +258,7 @@ class MainWindow : public QMainWindow, public PlatformInterface {
|
||||
void ScrobblingEnabledChanged(const bool value);
|
||||
void ScrobbleButtonVisibilityChanged(const bool value);
|
||||
void LoveButtonVisibilityChanged(const bool value);
|
||||
void SendNowPlaying();
|
||||
void Love();
|
||||
|
||||
void ExitFinished();
|
||||
|
||||
@@ -622,9 +622,8 @@ void Player::CurrentMetadataChanged(const Song &metadata) {
|
||||
if (app_->scrobbler()->IsEnabled() && engine_->state() == Engine::Playing) {
|
||||
Playlist *playlist = app_->playlist_manager()->active();
|
||||
current_item_ = playlist->current_item();
|
||||
if (playlist && current_item_ && !playlist->nowplaying() && current_item_->Metadata() == metadata && current_item_->Metadata().length_nanosec() > 0) {
|
||||
app_->scrobbler()->UpdateNowPlaying(metadata);
|
||||
playlist->set_nowplaying(true);
|
||||
if (playlist && current_item_ && !playlist->nowplaying() && current_item_->Metadata() == metadata && current_item_->Metadata().is_metadata_good()) {
|
||||
emit SendNowPlaying();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -121,6 +121,7 @@ class PlayerInterface : public QObject {
|
||||
// The toggle parameter is true when user requests to toggle visibility for Pretty OSD
|
||||
void ForceShowOSD(Song, bool toggle);
|
||||
|
||||
void SendNowPlaying();
|
||||
void Authenticated();
|
||||
|
||||
};
|
||||
|
||||
@@ -348,7 +348,7 @@ const QString &Song::cue_path() const { return d->cue_path_; }
|
||||
bool Song::has_cue() const { return !d->cue_path_.isEmpty(); }
|
||||
|
||||
bool Song::is_collection_song() const { return d->source_ == Source_Collection; }
|
||||
bool Song::is_metadata_good() const { return !d->title_.isEmpty() && !d->artist_.isEmpty() && !d->url_.isEmpty() && d->end_ > 0; }
|
||||
bool Song::is_metadata_good() const { return !d->url_.isEmpty() && !d->artist_.isEmpty() && !d->title_.isEmpty(); }
|
||||
bool Song::is_stream() const { return d->source_ == Source_Stream || d->source_ == Source_Tidal || d->source_ == Source_Subsonic || d->source_ == Source_Qobuz; }
|
||||
bool Song::is_cdda() const { return d->source_ == Source_CDDA; }
|
||||
bool Song::is_compilation() const { return (d->compilation_ || d->compilation_detected_ || d->compilation_on_) && !d->compilation_off_; }
|
||||
|
||||
Reference in New Issue
Block a user