2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Cancel state added for PlayButtonLayout in the new media player.

This commit is contained in:
John Preston
2016-10-09 20:08:16 +03:00
parent 3c8fb5f1f6
commit 8f135d7e00
8 changed files with 169 additions and 51 deletions

View File

@@ -209,6 +209,25 @@ void Instance::previous() {
moveInPlaylist(-1);
}
void Instance::playPauseCancelClicked() {
if (isSeeking()) {
return;
}
AudioMsgId playing;
auto playbackState = audioPlayer()->currentState(&playing, AudioMsgId::Type::Song);
auto stopped = ((playbackState.state & AudioPlayerStoppedMask) || playbackState.state == AudioPlayerFinishing);
auto showPause = !stopped && (playbackState.state == AudioPlayerPlaying || playbackState.state == AudioPlayerResuming || playbackState.state == AudioPlayerStarting);
auto audio = playing.audio();
if (audio && audio->loading()) {
audio->cancel();
} else if (showPause) {
pause();
} else {
play();
}
}
void Instance::startSeeking() {
_seeking = _current;
pause();