M module-apps/application-meditation/widgets/MeditationTimer.cpp => module-apps/application-meditation/widgets/MeditationTimer.cpp +7 -6
@@ 59,12 59,7 @@ namespace gui
application, *this, meditationTimerName, timerTick);
timer->attach(progressBar);
timer->attach(text);
- auto intervalCallback = [app = application] {
- AudioServiceAPI::PlaybackStart(app,
- audio::PlaybackType::Meditation,
- purefs::dir::getCurrentOSPath() / "assets/audio/meditation/gong.mp3");
- };
- timer->registerOnIntervalCallback(std::move(intervalCallback));
+ timer->registerOnIntervalCallback(std::bind(&MeditationTimer::playSound, this));
}
auto MeditationTimer::onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim) -> bool
@@ 89,4 84,10 @@ namespace gui
Expects(progressBar != nullptr);
return *progressBar;
}
+ void MeditationTimer::playSound()
+ {
+ AudioServiceAPI::PlaybackStart(application,
+ audio::PlaybackType::Meditation,
+ purefs::dir::getCurrentOSPath() / "assets/audio/meditation/gong.mp3");
+ }
} // namespace gui
M module-apps/application-meditation/widgets/MeditationTimer.hpp => module-apps/application-meditation/widgets/MeditationTimer.hpp +1 -0
@@ 33,6 33,7 @@ namespace gui
void setCounterVisible(bool isVisible) noexcept;
[[nodiscard]] app::TimerWithCallbacks &getTimer() noexcept;
[[nodiscard]] gui::Progress &getProgress() noexcept;
+ void playSound();
private:
void build();
M module-apps/application-meditation/windows/MeditationTimerWindow.cpp => module-apps/application-meditation/windows/MeditationTimerWindow.cpp +2 -0
@@ 78,11 78,13 @@ void MeditationTimerWindow::onBeforeShow(ShowMode mode, SwitchData *data)
auto onMeditationEnd = [&]() -> void {
setVisibleMeditationEnd();
application->refreshWindow(RefreshModes::GUI_REFRESH_DEEP);
+ timer->playSound();
};
timer->getTimer().registerOnFinishedCallback(onMeditationEnd);
timer->getTimer().reset(meditationTime, meditationIntervalPeriod);
timer->getTimer().start();
timer->getProgress().setMaximum(meditationTime.count());
+ timer->playSound();
application->refreshWindow(RefreshModes::GUI_REFRESH_DEEP);
};
timer->getTimer().registerOnFinishedCallback(onPreparation);