mirror of https://github.com/KDE/kasts.git
Set setPreventSleep in play() and pause()
Making it toggle based on the playerState did not work properly because the stream is toggling between pause and play several times in the prepareAudioStream method.
This commit is contained in:
parent
cbf0d9c622
commit
6edbd91f18
|
@ -283,15 +283,16 @@ void AudioManager::play()
|
|||
d->m_player.play();
|
||||
d->m_isSeekable = true;
|
||||
Q_EMIT seekableChanged(d->m_isSeekable);
|
||||
d->mPowerInterface.setPreventSleep(true);
|
||||
}
|
||||
|
||||
void AudioManager::pause()
|
||||
{
|
||||
//qDebug() << "AudioManager::pause";
|
||||
|
||||
d->m_player.play();
|
||||
d->m_isSeekable = true;
|
||||
d->m_player.pause();
|
||||
d->mPowerInterface.setPreventSleep(false);
|
||||
}
|
||||
|
||||
void AudioManager::playPause()
|
||||
|
@ -309,6 +310,7 @@ void AudioManager::stop()
|
|||
d->m_player.stop();
|
||||
d->m_isSeekable = false;
|
||||
Q_EMIT seekableChanged(d->m_isSeekable);
|
||||
d->mPowerInterface.setPreventSleep(false);
|
||||
}
|
||||
|
||||
void AudioManager::seek(qint64 position)
|
||||
|
@ -401,12 +403,14 @@ void AudioManager::playerStateChanged()
|
|||
d->mPowerInterface.setPreventSleep(false);
|
||||
break;
|
||||
case QMediaPlayer::State::PlayingState:
|
||||
// setPreventSleep is set in play() to avoid it toggling too rapidly
|
||||
// see d->prepareAudioStream() for details
|
||||
Q_EMIT playing();
|
||||
d->mPowerInterface.setPreventSleep(true);
|
||||
break;
|
||||
case QMediaPlayer::State::PausedState:
|
||||
// setPreventSleep is set in pause() to avoid it toggling too rapidly
|
||||
// see d->prepareAudioStream() for details
|
||||
Q_EMIT paused();
|
||||
d->mPowerInterface.setPreventSleep(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue