[vlc-devel] [PATCH 4/4] libvlc: media_player can now seek before play is called
Thomas Guillem
thomas at gllm.fr
Thu Jun 9 18:16:51 CEST 2016
---
include/vlc/libvlc_media_player.h | 3 +--
lib/media_player.c | 10 ++++++++++
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index 2323b4d..fad9a9e 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -752,7 +752,7 @@ 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).
* Not all formats and protocols support this.
*
* \param p_mi the Media Player
@@ -770,7 +770,6 @@ LIBVLC_API float libvlc_media_player_get_position( libvlc_media_player_t *p_mi )
/**
* Set movie position as percentage between 0.0 and 1.0.
- * This has no effect if playback is not enabled.
* This might not work depending on the underlying input format and protocol.
*
* \param p_mi the Media Player
diff --git a/lib/media_player.c b/lib/media_player.c
index a0860da..b44a065 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -601,6 +601,8 @@ libvlc_media_player_new( libvlc_instance_t *instance )
/* Input */
var_Create (mp, "rate", VLC_VAR_FLOAT|VLC_VAR_DOINHERIT);
+ var_Create (mp, "time", VLC_VAR_INTEGER);
+ var_Create (mp, "position", VLC_VAR_FLOAT);
/* Video */
var_Create (mp, "vout", VLC_VAR_STRING|VLC_VAR_DOINHERIT);
@@ -1324,7 +1326,11 @@ void libvlc_media_player_set_time( libvlc_media_player_t *p_mi,
p_input_thread = libvlc_get_input_thread ( p_mi );
if( !p_input_thread )
+ {
+ /* The input thread will inherit this var */
+ var_SetInteger( p_mi, "time", to_mtime(i_time) );
return;
+ }
var_SetInteger( p_input_thread, "time", to_mtime(i_time) );
vlc_object_release( p_input_thread );
@@ -1337,7 +1343,11 @@ void libvlc_media_player_set_position( libvlc_media_player_t *p_mi,
p_input_thread = libvlc_get_input_thread ( p_mi );
if( !p_input_thread )
+ {
+ /* The input thread will inherit this var */
+ var_SetFloat( p_mi, "position", position );
return;
+ }
var_SetFloat( p_input_thread, "position", position );
vlc_object_release( p_input_thread );
--
2.8.1
More information about the vlc-devel
mailing list