Skip to content

Commit

Permalink
MythMusic: Stop playback when exiting the import music screen
Browse files Browse the repository at this point in the history
This stops playback when exiting the screen if the current track was played
from the import music screen.
  • Loading branch information
Paul Harrison committed Aug 9, 2013
1 parent 315ec24 commit 5de9c61
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
2 changes: 1 addition & 1 deletion mythplugins/mythmusic/mythmusic/importmusic.cpp
Expand Up @@ -121,7 +121,7 @@ ImportMusicDialog::~ImportMusicDialog()
if (gPlayer->getCurrentMetadata() && m_playingMetaData)
{
if (gPlayer->isPlaying() && gPlayer->getCurrentMetadata()->Filename() == m_playingMetaData->Filename())
gPlayer->next();
gPlayer->stop();
}

if (m_locationEdit)
Expand Down
37 changes: 23 additions & 14 deletions mythplugins/mythmusic/mythmusic/musicplayer.cpp
Expand Up @@ -480,7 +480,7 @@ void MusicPlayer::nextAuto(void)
{
delete m_oneshotMetadata;
m_oneshotMetadata = NULL;
play();
stop(true);
return;
}

Expand Down Expand Up @@ -794,24 +794,33 @@ void MusicPlayer::customEvent(QEvent *event)
}
else if (event->type() == DecoderEvent::Finished)
{
if (m_playMode == PLAYMODE_TRACKS && m_currentMetadata &&
m_currentTime != m_currentMetadata->Length() / 1000)
if (m_oneshotMetadata)
{
delete m_oneshotMetadata;
m_oneshotMetadata = NULL;
stop(true);
}
else
{
LOG(VB_GENERAL, LOG_NOTICE, QString("MusicPlayer: Updating track length was %1s, should be %2s")
.arg(m_currentMetadata->Length() / 1000).arg(m_currentTime));
if (m_playMode == PLAYMODE_TRACKS && m_currentMetadata &&
m_currentTime != m_currentMetadata->Length() / 1000)
{
LOG(VB_GENERAL, LOG_NOTICE, QString("MusicPlayer: Updating track length was %1s, should be %2s")
.arg(m_currentMetadata->Length() / 1000).arg(m_currentTime));

m_currentMetadata->setLength(m_currentTime * 1000);
m_currentMetadata->dumpToDatabase();
m_currentMetadata->setLength(m_currentTime * 1000);
m_currentMetadata->dumpToDatabase();

// this will update any track lengths displayed on screen
gPlayer->sendMetadataChangedEvent(m_currentMetadata->ID());
// this will update any track lengths displayed on screen
gPlayer->sendMetadataChangedEvent(m_currentMetadata->ID());

// this will force the playlist stats to update
MusicPlayerEvent me(MusicPlayerEvent::TrackChangeEvent, m_currentTrack);
dispatch(me);
}
// this will force the playlist stats to update
MusicPlayerEvent me(MusicPlayerEvent::TrackChangeEvent, m_currentTrack);
dispatch(me);
}

nextAuto();
nextAuto();
}
}
else if (event->type() == DecoderEvent::Stopped)
{
Expand Down

0 comments on commit 5de9c61

Please sign in to comment.