diff --git a/src/gui/audioplayer.cpp b/src/gui/audioplayer.cpp index d91becad8..c18f01eb6 100644 --- a/src/gui/audioplayer.cpp +++ b/src/gui/audioplayer.cpp @@ -71,6 +71,7 @@ extern CPictureViewer * g_PicViewer; #include #include #include +#include #include #include @@ -2091,11 +2092,7 @@ void CAudioPlayerGui::stop() if (CAudioPlayer::getInstance()->getState() != CBaseDec::STOP) CAudioPlayer::getInstance()->stop(); - if (m_stationlogo) - { - unlink(m_cover.c_str()); - m_stationlogo = false; - } + cleanupCovers(); if (m_streamripper_active) { @@ -2168,6 +2165,8 @@ void CAudioPlayerGui::play(unsigned int pos) unsigned int old_current = m_current; unsigned int old_selected = m_selected; + cleanupCovers(); + m_current = pos; if (g_settings.audioplayer_follow) m_selected = pos; @@ -2927,3 +2926,28 @@ std::string CAudioPlayerGui::absPath2Rel(const std::string& fromDir, res = res + relFilepath; return res; } + +void CAudioPlayerGui::cleanupCovers() +{ + if (access(COVERDIR, F_OK) == 0) + { + struct dirent **coverlist; + int n = scandir(COVERDIR, &coverlist, 0, alphasort); + if (n > -1) + { + while (n--) + { + const char *coverfile = coverlist[n]->d_name; + if (strcmp(coverfile, ".") == 0 || strcmp(coverfile, "..") == 0) + continue; + printf("[audioplayer] removing cover %s/%s\n", COVERDIR, coverfile); + unlink(((std::string)COVERDIR + "/" + coverfile).c_str()); + free(coverlist[n]); + } + free(coverlist); + } + } + + m_cover.clear(); + m_stationlogo = false; +} diff --git a/src/gui/audioplayer.h b/src/gui/audioplayer.h index f61706e65..e5c6f41c5 100644 --- a/src/gui/audioplayer.h +++ b/src/gui/audioplayer.h @@ -234,6 +234,8 @@ class CAudioPlayerGui : public CMenuTarget */ bool askToOverwriteFile(const std::string& filename); + void cleanupCovers(); + bool openFilebrowser(void); bool openSCbrowser(void); bool clearPlaylist(void);