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) ...@@ -176,38 +176,16 @@ void PlayerManager::setPlaylistInterface(PlaylistInterface *interface)
void PlayerManager::play(const FileHandle &file) void PlayerManager::play(const FileHandle &file)
{ {
if(!m_media || !m_playlistInterface) if(!m_media || !m_playlistInterface || file.isNull())
return; return;
if(file.isNull()) { m_media->setCurrentSource(QUrl::fromLocalFile(file.absFilePath()));
if(paused()) m_media->play();
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();
if(m_file != file) if(m_file != file)
emit signalItemChanged(file); emit signalItemChanged(file);
m_file = file; m_file = file;
}
// Our state changed handler will perform the follow up actions necessary // Our state changed handler will perform the follow up actions necessary
// once we actually start playing. // once we actually start playing.
...@@ -224,7 +202,18 @@ void PlayerManager::play(const QString &file) ...@@ -224,7 +202,18 @@ void PlayerManager::play(const QString &file)
void PlayerManager::play() 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() void PlayerManager::pause()
......
...@@ -79,7 +79,7 @@ public: ...@@ -79,7 +79,7 @@ public:
public slots: public slots:
void play(const FileHandle &file); void play(const FileHandle &file);
void play(const QString &file); void play(const QString &file);
void play(); void play(); // start or restart playback
void pause(); void pause();
void stop(); void stop();
void setVolume(float volume = 1.0); 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