Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions mpd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,27 @@ void CMPD::Update()
int newsongpos = mpd_status_get_elapsed_time(status);
int curplaytime = mpd_stats_get_play_time(stats);

mpd_song *song = mpd_run_current_song(_conn);
Song *song_ = song ? new Song(song) : NULL;

// new song
if(newsongid != _songid) {
if(newsongid != _songid or (song_ and _song != *song_)) {
_songid = newsongid;
_songpos = newsongpos;
_start = curplaytime;

mpd_song *song = mpd_run_current_song(_conn);
if(song) {
GotNewSong(song);
mpd_song_free(song);
song = NULL;
}
}

if (song)
mpd_song_free(song);
if (song_)
delete song_;

// song playing
if(newsongpos != _songpos) {
_songpos = newsongpos;
Expand Down
6 changes: 6 additions & 0 deletions mpd.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ class Song {
std::string getTitle() const { return title; }
std::string getAlbum() const { return album; }
int getDuration() const { return duration; }

bool operator != (const Song &other) const {
return this->getArtist() != other.getArtist() or
this->getAlbum() != other.getAlbum() or
this->getTitle() != other.getTitle();
}
private:
std::string artist, title, album;
int duration;
Expand Down