Browse Source

lib: media_player: add jump_time

pull/162/head
Thomas Guillem 2 years ago
parent
commit
e077ccd68d
  1. 21
      include/vlc/libvlc_media_player.h
  2. 1
      lib/libvlc.sym
  3. 19
      lib/media_player.c

21
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.
*

1
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

19
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 )
{

Loading…
Cancel
Save