Changed: Automatically build playlist on play if needed

fix-media-player
Nimetu 5 years ago
parent b3f8f307b0
commit 682985978d

@ -353,6 +353,17 @@ void CMusicPlayer::play (sint index)
if(!SoundMngr)
return;
if (_Songs.empty())
{
index = 0;
createPlaylistFromMusic();
}
if (_Songs.empty())
{
_State = Stopped;
return;
}
sint prevSongIndex = _CurrentSongIndex;
@ -465,7 +476,10 @@ void CMusicPlayer::next ()
void CMusicPlayer::update ()
{
if(!SoundMngr)
{
_State = Stopped;
return;
}
if (MusicPlayerWorker.isRunning() || !_SongUpdateQueue.empty())
{
@ -564,23 +578,8 @@ static void addFromPlaylist(const std::string &playlist, const std::vector<std::
}
}
// ***************************************************************************
class CMusicPlayerPlaySongs: public IActionHandler
void CMusicPlayer::createPlaylistFromMusic()
{
public:
virtual void execute(CCtrlBase * /* pCaller */, const string &Params)
{
if(!SoundMngr)
{
// Do not show warning on volume change as its restored at startup
if (Params.find("volume") == std::string::npos)
CInterfaceManager::getInstance()->messageBox (CI18N::get ("uiMP3SoundDisabled"));
return;
}
if (Params == "play_songs")
{
std::vector<std::string> extensions;
SoundMngr->getMixer()->getMusicExtensions(extensions);
@ -633,7 +632,27 @@ public:
// Sort songs by filename
sort(filenames.begin(), filenames.end());
MusicPlayer.playSongs(filenames);
playSongs(filenames);
}
// ***************************************************************************
class CMusicPlayerPlaySongs: public IActionHandler
{
public:
virtual void execute(CCtrlBase * /* pCaller */, const string &Params)
{
if(!SoundMngr)
{
// Do not show warning on volume change as its restored at startup
if (Params.find("volume") == std::string::npos)
CInterfaceManager::getInstance()->messageBox (CI18N::get ("uiMP3SoundDisabled"));
return;
}
if (Params == "play_songs")
{
MusicPlayer.createPlaylistFromMusic();
}
else if (Params == "update_playlist")
{

@ -81,6 +81,9 @@ public:
// update song from worker thread
void updateSong(const std::string filename, const std::string title, float length);
// scan music folder and rebuild playlist
void createPlaylistFromMusic();
private:
// The playlist

Loading…
Cancel
Save