summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorZaggy1024 <zaggy1024@gmail.com>2023-02-06 04:11:32 -0600
committerAndreas Kling <kling@serenityos.org>2023-02-08 21:52:42 +0100
commitb0db56cd39e20035d426bb30a6e7bd76318bebee (patch)
treeaa5855e4861230648aabbd040a2ef7b39b99903e /Userland/Libraries
parent1f650088a0b4ae99b793ca13377e7e2238ded8d5 (diff)
downloadserenity-b0db56cd39e20035d426bb30a6e7bd76318bebee.zip
VideoPlayer/LibVideo: Seek accurately when scrolling in the seek bar
Fast seeking does not work correctly when seeking in small increments, so it is necessary to use accurate seeking when using certain actions. The PlaybackManager has been changed to accept the seek mode as a parameter to `seek_to_timestamp` to facilitate this. This now means that it no longer has to track a seek mode preference.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibVideo/PlaybackManager.cpp4
-rw-r--r--Userland/Libraries/LibVideo/PlaybackManager.h7
2 files changed, 3 insertions, 8 deletions
diff --git a/Userland/Libraries/LibVideo/PlaybackManager.cpp b/Userland/Libraries/LibVideo/PlaybackManager.cpp
index 9a808402b8..5a49f32bd2 100644
--- a/Userland/Libraries/LibVideo/PlaybackManager.cpp
+++ b/Userland/Libraries/LibVideo/PlaybackManager.cpp
@@ -109,9 +109,9 @@ void PlaybackManager::timer_callback()
TRY_OR_FATAL_ERROR(m_playback_handler->on_timer_callback());
}
-void PlaybackManager::seek_to_timestamp(Time target_timestamp)
+void PlaybackManager::seek_to_timestamp(Time target_timestamp, SeekMode seek_mode)
{
- TRY_OR_FATAL_ERROR(m_playback_handler->seek(target_timestamp, m_seek_mode));
+ TRY_OR_FATAL_ERROR(m_playback_handler->seek(target_timestamp, seek_mode));
}
Optional<Time> PlaybackManager::seek_demuxer_to_most_recent_keyframe(Time timestamp, Optional<Time> earliest_available_sample)
diff --git a/Userland/Libraries/LibVideo/PlaybackManager.h b/Userland/Libraries/LibVideo/PlaybackManager.h
index 3a92b2453d..39c42c09b1 100644
--- a/Userland/Libraries/LibVideo/PlaybackManager.h
+++ b/Userland/Libraries/LibVideo/PlaybackManager.h
@@ -98,15 +98,12 @@ public:
void resume_playback();
void pause_playback();
void restart_playback();
- void seek_to_timestamp(Time);
+ void seek_to_timestamp(Time, SeekMode = DEFAULT_SEEK_MODE);
bool is_playing() const
{
return m_playback_handler->is_playing();
}
- SeekMode seek_mode() { return m_seek_mode; }
- void set_seek_mode(SeekMode mode) { m_seek_mode = mode; }
-
u64 number_of_skipped_frames() const { return m_skipped_frames; }
void on_decoder_error(DecoderError error);
@@ -140,8 +137,6 @@ private:
Time m_last_present_in_media_time = Time::zero();
- SeekMode m_seek_mode = DEFAULT_SEEK_MODE;
-
NonnullOwnPtr<Demuxer> m_demuxer;
Track m_selected_video_track;
NonnullOwnPtr<VideoDecoder> m_decoder;