[vlc-commits] [Git][videolan/vlc][master] lib: media_player: add jump_time

Steve Lhomme (@robUx4) gitlab at videolan.org
Wed May 22 08:52:45 UTC 2024



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
e077ccd6 by Thomas Guillem at 2024-05-21T09:19:15+02:00
lib: media_player: add jump_time

- - - - -


3 changed files:

- include/vlc/libvlc_media_player.h
- lib/libvlc.sym
- lib/media_player.c


Changes:

=====================================
include/vlc/libvlc_media_player.h
=====================================
@@ -1227,17 +1227,34 @@ LIBVLC_API libvlc_time_t libvlc_media_player_get_length( libvlc_media_player_t *
 LIBVLC_API libvlc_time_t libvlc_media_player_get_time( libvlc_media_player_t *p_mi );
 
 /**
- * Set the movie time (in ms). This has no effect if no media is being played.
+ * Set the movie time (in ms).
+ *
+ * This has no effect if no media is being played.
  * Not all formats and protocols support this.
  *
  * \param p_mi the Media Player
- * \param b_fast prefer fast seeking or precise seeking
  * \param i_time the movie time (in ms).
+ * \param b_fast prefer fast seeking or precise seeking
  * \return 0 on success, -1 on error
  */
 LIBVLC_API int libvlc_media_player_set_time( libvlc_media_player_t *p_mi,
                                              libvlc_time_t i_time, bool b_fast );
 
+/**
+ * Jump the movie time (in ms).
+ *
+ * This will trigger a precise and relative seek (from the current time).
+ * This has no effect if no media is being played.
+ * Not all formats and protocols support this.
+ *
+ * \param p_mi the Media Player
+ * \param i_time the movie time (in ms).
+ * \return 0 on success, -1 on error
+ * \version LibVLC 4.0.0 and later.
+ */
+LIBVLC_API int libvlc_media_player_jump_time( libvlc_media_player_t *p_mi,
+                                              libvlc_time_t i_time );
+
 /**
  * Get movie position as percentage between 0.0 and 1.0.
  *


=====================================
lib/libvlc.sym
=====================================
@@ -174,6 +174,7 @@ libvlc_media_player_set_rate
 libvlc_media_player_set_renderer
 libvlc_media_player_set_role
 libvlc_media_player_set_time
+libvlc_media_player_jump_time
 libvlc_media_player_set_title
 libvlc_media_player_set_xwindow
 libvlc_media_player_stop_async


=====================================
lib/media_player.c
=====================================
@@ -1342,8 +1342,9 @@ libvlc_time_t libvlc_media_player_get_time( libvlc_media_player_t *p_mi )
     return i_time;
 }
 
-int libvlc_media_player_set_time( libvlc_media_player_t *p_mi,
-                                   libvlc_time_t i_time, bool b_fast )
+static int
+set_time( libvlc_media_player_t *p_mi, libvlc_time_t i_time, bool b_fast,
+          enum vlc_player_whence whence )
 {
     vlc_tick_t tick = vlc_tick_from_libvlc_time(i_time);
 
@@ -1352,7 +1353,7 @@ int libvlc_media_player_set_time( libvlc_media_player_t *p_mi,
 
     enum vlc_player_seek_speed speed = b_fast ? VLC_PLAYER_SEEK_FAST
                                               : VLC_PLAYER_SEEK_PRECISE;
-    vlc_player_SeekByTime(player, tick, speed, VLC_PLAYER_WHENCE_ABSOLUTE);
+    vlc_player_SeekByTime(player, tick, speed, whence);
 
     vlc_player_Unlock(player);
 
@@ -1360,6 +1361,18 @@ int libvlc_media_player_set_time( libvlc_media_player_t *p_mi,
     return 0;
 }
 
+int libvlc_media_player_set_time( libvlc_media_player_t *p_mi,
+                                  libvlc_time_t i_time, bool b_fast )
+{
+    return set_time( p_mi, i_time, b_fast, VLC_PLAYER_WHENCE_ABSOLUTE );
+}
+
+int libvlc_media_player_jump_time( libvlc_media_player_t *p_mi,
+                                   libvlc_time_t i_time )
+{
+    return set_time( p_mi, i_time, false, VLC_PLAYER_WHENCE_RELATIVE );
+}
+
 int libvlc_media_player_set_position( libvlc_media_player_t *p_mi,
                                       double position, bool b_fast )
 {



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/e077ccd68df9b59949e7669b136e99bca7a0918e

-- 
This project does not include diff previews in email notifications.
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/e077ccd68df9b59949e7669b136e99bca7a0918e
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list