diff --git a/src/gui/audioplayer.cpp b/src/gui/audioplayer.cpp index ba2b2bf59..86577d6f7 100644 --- a/src/gui/audioplayer.cpp +++ b/src/gui/audioplayer.cpp @@ -72,6 +72,7 @@ extern CPictureViewer * g_PicViewer; #include #include #include +#include #include #include @@ -1958,11 +1959,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(); } void CAudioPlayerGui::pause() @@ -2028,6 +2025,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; @@ -2786,3 +2785,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 683d06c25..e62aa1422 100644 --- a/src/gui/audioplayer.h +++ b/src/gui/audioplayer.h @@ -232,6 +232,8 @@ class CAudioPlayerGui : public CMenuTarget */ bool askToOverwriteFile(const std::string& filename); + void cleanupCovers(); + bool openFilebrowser(void); bool openSCbrowser(void); bool clearPlaylist(void);