diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 4fe1a5f93..465e6f315 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -302,9 +302,9 @@ void MainWindow::MediaPlaying() { ui_.action_play_pause->setText("Pause"); ui_.action_play_pause->setEnabled( - ! (playlist_->current_item_options() & PlaylistItem::PauseDisabled)); + ! (player_->GetCurrentItemOptions() & PlaylistItem::PauseDisabled)); - bool is_lastfm = (playlist_->current_item_options() & PlaylistItem::LastFMControls); + bool is_lastfm = (player_->GetCurrentItemOptions() & PlaylistItem::LastFMControls); LastFMService* lastfm = radio_model_->GetLastFMService(); ui_.action_ban->setEnabled(lastfm->IsScrobblingEnabled() && is_lastfm); @@ -320,7 +320,7 @@ void MainWindow::ScrobblingEnabledChanged(bool value) { if (!player_->GetState() == Engine::Idle) return; - bool is_lastfm = (playlist_->current_item_options() & PlaylistItem::LastFMControls); + bool is_lastfm = (player_->GetCurrentItemOptions() & PlaylistItem::LastFMControls); ui_.action_ban->setEnabled(value && is_lastfm); ui_.action_love->setEnabled(value); } @@ -406,7 +406,7 @@ void MainWindow::FilePathChanged(const QString& path) { void MainWindow::UpdateTrackPosition() { // Track position in seconds const int position = std::floor(float(player_->GetEngine()->position()) / 1000.0 + 0.5); - const int length = playlist_->current_item()->Metadata().length(); + const int length = player_->GetCurrentItem().length(); if (length <= 0) { // Probably a stream that we don't know the length of diff --git a/src/player.cpp b/src/player.cpp index 360927416..2edeb62c3 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -9,6 +9,7 @@ Player::Player(Playlist* playlist, LastFMService* lastfm, QObject* parent) : QObject(parent), playlist_(playlist), lastfm_(lastfm), + current_item_options_(PlaylistItem::Default), engine_(new XineEngine) { if (!engine_->init()) { @@ -57,7 +58,7 @@ void Player::PlayPause() { case Engine::Playing: // We really shouldn't pause last.fm streams - if (playlist_->current_item()->options() & PlaylistItem::PauseDisabled) + if (current_item_options_ & PlaylistItem::PauseDisabled) break; qDebug() << "Pausing"; @@ -122,6 +123,8 @@ void Player::PlayAt(int index) { playlist_->set_current_index(index); PlaylistItem* item = playlist_->item_at(index); + current_item_options_ = item->options(); + current_item_ = item->Metadata(); if (item->options() & PlaylistItem::SpecialPlayBehaviour) item->StartLoading(); diff --git a/src/player.h b/src/player.h index b0ce222ac..fd9591ae8 100644 --- a/src/player.h +++ b/src/player.h @@ -5,6 +5,8 @@ #include #include "engine_fwd.h" +#include "playlistitem.h" +#include "song.h" class Playlist; class Settings; @@ -20,6 +22,9 @@ class Player : public QObject { Engine::State GetState() const; int GetVolume() const; + PlaylistItem::Options GetCurrentItemOptions() const { return current_item_options_; } + Song GetCurrentItem() const { return current_item_; } + public slots: void PlayAt(int index); void PlayPause(); @@ -47,6 +52,9 @@ class Player : public QObject { LastFMService* lastfm_; QSettings settings_; + PlaylistItem::Options current_item_options_; + Song current_item_; + EngineBase* engine_; };