mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-21 12:29:04 -06:00
Make seeking use set property with time-pos instead of command
This commit is contained in:
@@ -56,7 +56,7 @@ public:
|
||||
void play();
|
||||
void goToStart();
|
||||
|
||||
void seekToTime(double time);
|
||||
void seekToTime(double time, bool pauseAfter = false);
|
||||
void toggleMute();
|
||||
|
||||
const std::unique_ptr<ghoul::opengl::Texture>& frameTexture() const;
|
||||
|
||||
@@ -332,7 +332,7 @@ VideoPlayer::VideoPlayer(const ghoul::Dictionary& dictionary)
|
||||
{MpvKey::Width, MPV_FORMAT_INT64},
|
||||
{MpvKey::Meta, MPV_FORMAT_NODE},
|
||||
{MpvKey::Fps, MPV_FORMAT_DOUBLE},
|
||||
{MpvKey::IsSeeking, MPV_FORMAT_DOUBLE},
|
||||
{MpvKey::IsSeeking, MPV_FORMAT_FLAG},
|
||||
{MpvKey::Mute, MPV_FORMAT_STRING}
|
||||
};
|
||||
|
||||
@@ -475,20 +475,14 @@ void VideoPlayer::initializeMpv() {
|
||||
_isInitialized = true;
|
||||
}
|
||||
|
||||
void VideoPlayer::seekToTime(double time) {
|
||||
if (!_isInitialized) {
|
||||
void VideoPlayer::seekToTime(double time, bool pauseAfter) {
|
||||
if (_isSeeking || abs(_currentVideoTime - time) < glm::epsilon<double>()) {
|
||||
return;
|
||||
}
|
||||
// Prevent from seeking to the same time multiple times in a row
|
||||
bool seekIsDifferent = abs(time - _currentVideoTime) > _seekThreshold;
|
||||
if (seekIsDifferent && !_isSeeking) {
|
||||
// Pause while seeking
|
||||
pause();
|
||||
std::string timeString = std::to_string(time);
|
||||
const char* params = timeString.c_str();
|
||||
const char* cmd[] = { keys[MpvKey::Seek], params, "absolute", NULL};
|
||||
commandAsyncMpv(cmd, MpvKey::Seek);
|
||||
_isSeeking = true;
|
||||
pause();
|
||||
setPropertyAsyncMpv(time, MpvKey::Time);
|
||||
if (!pauseAfter) {
|
||||
play();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -605,7 +599,6 @@ void VideoPlayer::handleMpvEvents() {
|
||||
break;
|
||||
}
|
||||
case MpvKey::Seek: {
|
||||
_isSeeking = false;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
@@ -714,6 +707,7 @@ void VideoPlayer::handleMpvProperties(mpv_event* event) {
|
||||
}
|
||||
case MpvKey::IsSeeking: {
|
||||
bool* isSeekingBool = reinterpret_cast<bool*>(prop->data);
|
||||
_isSeeking = *isSeekingBool;
|
||||
std::string isSeekingString = *isSeekingBool ? "Is Seeking" : "Not Seeking";
|
||||
LINFO(isSeekingString);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user