Commit d5123cc6 authored by Michael Pyne's avatar Michael Pyne

PlayerManager: Move the start/restart handler where it belongs.

This makes the playback handler that accepts a FileHandle on purpose a
bit easier to think through.
parent 387818ec
......@@ -176,38 +176,16 @@ void PlayerManager::setPlaylistInterface(PlaylistInterface *interface)
void PlayerManager::play(const FileHandle &file)
{
if(!m_media || !m_playlistInterface)
if(!m_media || !m_playlistInterface || file.isNull())
return;
if(file.isNull()) {
if(paused())
m_media->play();
else if(playing()) {
m_media->seek(0);
emit seeked(0);
}
else {
m_playlistInterface->playNext();
m_file = m_playlistInterface->currentFile();
if(!m_file.isNull())
{
m_media->setCurrentSource(QUrl::fromLocalFile(m_file.absFilePath()));
m_media->play();
emit signalItemChanged(m_file);
}
}
}
else {
m_media->setCurrentSource(QUrl::fromLocalFile(file.absFilePath()));
m_media->play();
m_media->setCurrentSource(QUrl::fromLocalFile(file.absFilePath()));
m_media->play();
if(m_file != file)
emit signalItemChanged(file);
if(m_file != file)
emit signalItemChanged(file);
m_file = file;
}
m_file = file;
// Our state changed handler will perform the follow up actions necessary
// once we actually start playing.
......@@ -224,7 +202,18 @@ void PlayerManager::play(const QString &file)
void PlayerManager::play()
{
play(FileHandle());
if(paused())
m_media->play();
else if(playing()) {
m_media->seek(0);
emit seeked(0);
}
else {
m_playlistInterface->playNext();
const auto file = m_playlistInterface->currentFile();
play(file);
}
}
void PlayerManager::pause()
......
......@@ -79,7 +79,7 @@ public:
public slots:
void play(const FileHandle &file);
void play(const QString &file);
void play();
void play(); // start or restart playback
void pause();
void stop();
void setVolume(float volume = 1.0);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment