Browse Source

libvlc: add new API to set AB loop explicitly

Adds:

 - libvlc_media_player_set_abloop_time
 - libvlc_media_player_set_abloop_position
 - libvlc_media_player_reset_abloop

These new methods allow to set a specific start and end time or
position to setup an AB loop, and a way to remove the loop.

There must be an active input before setting the AB loop.
pull/176/head
Mark Lee 2 years ago
committed by Steve Lhomme
parent
commit
07d1509872
  1. 42
      include/vlc/libvlc_media_player.h
  2. 3
      lib/libvlc.sym
  3. 46
      lib/media_player.c

42
include/vlc/libvlc_media_player.h

@ -1335,6 +1335,48 @@ LIBVLC_API int
libvlc_media_player_set_abloop( libvlc_media_player_t *p_mi,
libvlc_abloop_t abloop );
/**
* Enable A to B loop for the current media by setting the start time and end
* time
*
* The B time must be higher than the A time.
*
* \param p_mi the Media Player
* \param a_time start time for the loop (in ms)
* \param b_time end time for the loop (in ms)
* \return 0 on success, -1 on error
* \version LibVLC 4.0.0 and later.
*/
LIBVLC_API int
libvlc_media_player_set_abloop_time( libvlc_media_player_t *p_mi,
libvlc_time_t a_time, libvlc_time_t b_time );
/**
* Enable A to B loop for the current media by setting the start position and
* end position
*
* The B position must be higher than the A position.
*
* \param p_mi the Media Player
* \param a_pos start position for the loop
* \param b_pos end position for the loop
* \return 0 on success, -1 on error
* \version LibVLC 4.0.0 and later.
*/
LIBVLC_API int
libvlc_media_player_set_abloop_position( libvlc_media_player_t *p_mi,
double a_pos, double b_pos );
/**
* Reset/remove the A to B loop for the current media
*
* \param p_mi the Media Player
* \return 0 on success, -1 on error
* \version LibVLC 4.0.0 and later.
*/
LIBVLC_API int
libvlc_media_player_reset_abloop( libvlc_media_player_t *p_mi );
/**
* Get the A to B loop status
*

3
lib/libvlc.sym

@ -188,6 +188,9 @@ libvlc_media_player_unselect_track_type
libvlc_media_player_select_tracks
libvlc_media_player_select_tracks_by_ids
libvlc_media_player_set_abloop
libvlc_media_player_set_abloop_time
libvlc_media_player_set_abloop_position
libvlc_media_player_reset_abloop
libvlc_media_player_get_abloop
libvlc_player_program_delete
libvlc_player_programlist_count

46
lib/media_player.c

@ -1415,6 +1415,52 @@ libvlc_media_player_set_abloop( libvlc_media_player_t *p_mi,
return ret;
}
int
libvlc_media_player_set_abloop_time( libvlc_media_player_t *p_mi,
libvlc_time_t a_time, libvlc_time_t b_time )
{
vlc_tick_t a_tick = vlc_tick_from_libvlc_time(a_time);
if (a_tick >= 0)
a_tick += VLC_TICK_0;
vlc_tick_t b_tick = vlc_tick_from_libvlc_time(b_time);
if (b_tick >= 0)
b_tick += VLC_TICK_0;
vlc_player_t *player = p_mi->player;
vlc_player_Lock(player);
int ret = vlc_player_SetAtoBLoopTime(player, a_tick, b_tick);
vlc_player_Unlock(player);
return ret == VLC_SUCCESS ? 0 : -1;
}
int
libvlc_media_player_set_abloop_position( libvlc_media_player_t *p_mi,
double a_pos, double b_pos )
{
vlc_player_t *player = p_mi->player;
vlc_player_Lock(player);
int ret = vlc_player_SetAtoBLoopPosition(player, a_pos, b_pos);
vlc_player_Unlock(player);
return ret == VLC_SUCCESS ? 0 : -1;
}
int
libvlc_media_player_reset_abloop( libvlc_media_player_t *p_mi )
{
vlc_player_t *player = p_mi->player;
vlc_player_Lock(player);
int ret = vlc_player_ResetAtoBLoop(player);
vlc_player_Unlock(player);
return ret == VLC_SUCCESS ? 0 : -1;
}
libvlc_abloop_t
libvlc_media_player_get_abloop( libvlc_media_player_t *p_mi,
libvlc_time_t *a_time, double *a_pos,

Loading…
Cancel
Save