Skip to content
Permalink
Browse files

MythMusic: Add some additional events to the music player.

These events will be sent on music stats changed, albumart image changed and
CD changed.
  • Loading branch information...
Paul Harrison
Paul Harrison committed Feb 27, 2011
1 parent 93d8997 commit 58f8352285dbeb0eccd16687b7b938eaa30bf496
Showing with 32 additions and 19 deletions.
  1. +25 −19 mythplugins/mythmusic/mythmusic/musicplayer.cpp
  2. +7 −0 mythplugins/mythmusic/mythmusic/musicplayer.h
@@ -35,6 +35,9 @@ QEvent::Type MusicPlayerEvent::TrackAddedEvent = (QEvent::Type) QEvent::register
QEvent::Type MusicPlayerEvent::TrackRemovedEvent = (QEvent::Type) QEvent::registerEventType();
QEvent::Type MusicPlayerEvent::AllTracksRemovedEvent = (QEvent::Type) QEvent::registerEventType();
QEvent::Type MusicPlayerEvent::MetadataChangedEvent = (QEvent::Type) QEvent::registerEventType();
QEvent::Type MusicPlayerEvent::TrackStatsChangedEvent = (QEvent::Type) QEvent::registerEventType();
QEvent::Type MusicPlayerEvent::AlbumArtChangedEvent = (QEvent::Type) QEvent::registerEventType();
QEvent::Type MusicPlayerEvent::CDChangedEvent = (QEvent::Type) QEvent::registerEventType();

MusicPlayer::MusicPlayer(QObject *parent, const QString &dev)
:QObject(parent)
@@ -916,26 +919,11 @@ MusicPlayer::ShuffleMode MusicPlayer::toggleShuffleMode(void)

void MusicPlayer::updateLastplay()
{
// FIXME this is ugly having to keep two metadata objects in sync
if (m_currentNode && m_currentNode->getInt() > 0)
if (m_currentMetadata)
{
if (m_currentMetadata)
{
m_currentMetadata->incPlayCount();
m_currentMetadata->setLastPlay();
sendMetadataChangedEvent(m_currentMetadata->ID());
}
// if all_music is still in scope we need to keep that in sync
// if (gMusicData->all_music)
// {
// Metadata *mdata
// = gMusicData->all_music->getMetadata(m_currentNode->getInt());
// if (mdata)
// {
// mdata->incPlayCount();
// mdata->setLastPlay();
// }
// }
m_currentMetadata->incPlayCount();
m_currentMetadata->setLastPlay();
sendTrackStatsChangedEvent(m_currentMetadata->ID());
}

m_updatedLastplay = true;
@@ -974,6 +962,24 @@ void MusicPlayer::sendMetadataChangedEvent(int trackID)
dispatch(me);
}

void MusicPlayer::sendTrackStatsChangedEvent(int trackID)
{
MusicPlayerEvent me(MusicPlayerEvent::TrackStatsChangedEvent, trackID);
dispatch(me);
}

void MusicPlayer::sendAlbumArtChangedEvent(int trackID)
{
MusicPlayerEvent me(MusicPlayerEvent::AlbumArtChangedEvent, trackID);
dispatch(me);
}

void MusicPlayer::sendCDChangedEvent(void)
{
MusicPlayerEvent me(MusicPlayerEvent::CDChangedEvent, -1);
dispatch(me);
}

void MusicPlayer::incVolume()
{
if (getOutput())
@@ -12,6 +12,7 @@

class AudioOutput;
class MainVisual;
class Playlist;

class MusicPlayerEvent : public MythEvent
{
@@ -37,6 +38,9 @@ class MusicPlayerEvent : public MythEvent
static Type TrackRemovedEvent;
static Type AllTracksRemovedEvent;
static Type MetadataChangedEvent;
static Type TrackStatsChangedEvent;
static Type AlbumArtChangedEvent;
static Type CDChangedEvent;
};

class MusicPlayer : public QObject, public MythObservable
@@ -117,6 +121,9 @@ class MusicPlayer : public QObject, public MythObservable
Metadata *getDisplayMetadata(void) { return &m_displayMetadata; }
void refreshMetadata(void);
void sendMetadataChangedEvent(int trackID);
void sendTrackStatsChangedEvent(int trackID);
void sendAlbumArtChangedEvent(int trackID);
void sendCDChangedEvent(void);

void toMap(QHash<QString, QString> &infoMap);

0 comments on commit 58f8352

Please sign in to comment.
You can’t perform that action at this time.