Fixed seeking of slider from audio player in touchbar.

This commit is contained in:
23rd 2019-05-04 10:01:10 +03:00 committed by John Preston
parent 62a6812259
commit 9873e6d75c
1 changed files with 9 additions and 2 deletions

View File

@ -484,8 +484,15 @@ auto lifetime = rpl::lifetime();
}
- (void) seekbarChanged:(NSSliderTouchBarItem *)sender {
Core::Sandbox::Instance().customEnterFromEventLoop([&] {
Media::Player::instance()->finishSeeking(kSongType, sender.slider.doubleValue);
// https://stackoverflow.com/a/45891017
NSEvent *event = [[NSApplication sharedApplication] currentEvent];
bool touchUp = [event touchesMatchingPhase:NSTouchPhaseEnded inView:nil].count > 0;
Core::Sandbox::Instance().customEnterFromEventLoop([=] {
if (touchUp) {
Media::Player::instance()->finishSeeking(kSongType, sender.slider.doubleValue);
} else {
Media::Player::instance()->startSeeking(kSongType);
}
});
}