Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Mythmusic immediatly save playlists #28

Closed
wants to merge 3 commits into from

2 participants

@tobser

Added some minor changes for mythmusic to immediately save the playlists to the database as soon as they are changed.

@stuartm
Owner

Believe Paul has already added this functionality.

@stuartm stuartm closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
24 mythplugins/mythmusic/mythmusic/musiccommon.cpp
@@ -511,6 +511,7 @@ bool MusicCommon::keyPressEvent(QKeyEvent *e)
{
m_movingTrack = false;
item->DisplayState("off", "movestate");
+ storePlaylists();
}
else if (action == "UP")
{
@@ -691,7 +692,10 @@ bool MusicCommon::keyPressEvent(QKeyEvent *e)
{
Metadata *mdata = qVariantValue<Metadata*> (item->GetData());
if (mdata)
+ {
gPlayer->removeTrack(mdata->ID());
+ storePlaylists();
+ }
}
}
else if (action == "MENU")
@@ -1309,13 +1313,17 @@ void MusicCommon::customEvent(QEvent *event)
{
Metadata *mdata = qVariantValue<Metadata*> (item->GetData());
if (mdata)
+ {
gPlayer->removeTrack(mdata->ID());
+ storePlaylists();
+ }
}
}
else if (resulttext == tr("Remove All Tracks"))
{
gPlayer->getPlaylist()->removeAllTracks();
gPlayer->activePlaylistChanged(-1, true);
+ storePlaylists();
}
else if (resulttext == tr("Save To New Playlist"))
{
@@ -1384,6 +1392,7 @@ void MusicCommon::customEvent(QEvent *event)
int mode = dce->GetData().toInt();
gPlayer->setShuffleMode((MusicPlayer::ShuffleMode) mode);
updateShuffleMode(true);
+ storePlaylists();
}
else if (resultid == "exitmenu")
{
@@ -1435,6 +1444,7 @@ void MusicCommon::customEvent(QEvent *event)
byYear();
else if (resulttext == tr("Tracks With Same Title"))
byTitle();
+
}
else if (resultid == "playlistoptionsmenu")
{
@@ -1442,11 +1452,13 @@ void MusicCommon::customEvent(QEvent *event)
{
m_playlistOptions.insertPLOption = PL_REPLACE;
doUpdatePlaylist();
+ storePlaylists();
}
else if (resulttext == tr("Add Tracks"))
{
m_playlistOptions.insertPLOption = PL_INSERTATEND;
doUpdatePlaylist();
+ storePlaylists();
}
}
else if (resultid == "visualizermenu")
@@ -1464,6 +1476,7 @@ void MusicCommon::customEvent(QEvent *event)
gMusicData->all_playlists->copyNewPlaylist(resulttext);
Playlist *playlist = gMusicData->all_playlists->getPlaylist(resulttext);
gPlayer->playlistChanged(playlist->getID());
+ storePlaylists();
}
else if (resultid == "updateplaylist")
{
@@ -1472,6 +1485,7 @@ void MusicCommon::customEvent(QEvent *event)
playlist->removeAllTracks();
playlist->fillSongsFromSonglist(songList);
gPlayer->playlistChanged(playlist->getID());
+ storePlaylists();
}
}
else if (event->type() == MusicPlayerEvent::TrackChangeEvent)
@@ -2406,6 +2420,7 @@ void MusicCommon::doUpdatePlaylist(void)
m_whereClause, true,
m_playlistOptions.insertPLOption, curTrackID);
m_whereClause.clear();
+
}
else if (!m_songList.isEmpty())
{
@@ -2505,6 +2520,15 @@ void MusicCommon::playFirstTrack()
gPlayer->setCurrentTrackPos(0);
}
+void MusicCommon::storePlaylists(void)
+{
+ if (gMusicData->all_playlists->cleanOutThreads())
+ {
+ gMusicData->all_playlists->save();
+ LOG(VB_GENERAL, LOG_INFO, "Playlists saved.");
+ }
+}
+
//---------------------------------------------------------
// MythMusicVolumeDialog
//---------------------------------------------------------
View
1  mythplugins/mythmusic/mythmusic/musiccommon.h
@@ -101,6 +101,7 @@ class MPUBLIC MusicCommon : public MythScreenType
protected:
void showExitMenu(void);
void showPlaylistOptionsMenu(bool addMainMenu = false);
+ void storePlaylists(void);
protected:
QString getTimeString(int exTime, int maxTime);
Something went wrong with that request. Please try again.