Commit ab363722 authored by Antoine Cellerier's avatar Antoine Cellerier

Remove msecseek command. Now seek works differently depending on the argument:

control media seek 10   -> seek to position 10% (previous behavior)
control media seek +10  -> seek 10% forward
control media seed -10  -> seek 10% backwards
control media seek 10s  -> seek to position 10s (works with +- too)
control media seek 10ms -> seel to position 10ms (works with +- too)
parent 25b9b158
...@@ -613,8 +613,7 @@ static int ExecuteCommand( vlm_t *p_vlm, const char *psz_command, ...@@ -613,8 +613,7 @@ static int ExecuteCommand( vlm_t *p_vlm, const char *psz_command,
if( strcmp( ppsz_command[2], "play" ) && if( strcmp( ppsz_command[2], "play" ) &&
strcmp( ppsz_command[2], "stop" ) && strcmp( ppsz_command[2], "stop" ) &&
strcmp( ppsz_command[2], "pause" ) && strcmp( ppsz_command[2], "pause" ) &&
strcmp( ppsz_command[2], "seek" ) && strcmp( ppsz_command[2], "seek" ) )
strcmp( ppsz_command[2], "msecseek" ) )
{ {
i_index++; i_index++;
psz_instance = ppsz_command[2]; psz_instance = ppsz_command[2];
...@@ -624,8 +623,7 @@ static int ExecuteCommand( vlm_t *p_vlm, const char *psz_command, ...@@ -624,8 +623,7 @@ static int ExecuteCommand( vlm_t *p_vlm, const char *psz_command,
if( strcmp( ppsz_command[3], "play" ) && if( strcmp( ppsz_command[3], "play" ) &&
strcmp( ppsz_command[3], "stop" ) && strcmp( ppsz_command[3], "stop" ) &&
strcmp( ppsz_command[3], "pause" ) && strcmp( ppsz_command[3], "pause" ) &&
strcmp( ppsz_command[3], "seek" ) && strcmp( ppsz_command[3], "seek" ) )
strcmp( ppsz_command[3], "msecseek" ) )
goto syntax_error; goto syntax_error;
} }
...@@ -1268,36 +1266,65 @@ int vlm_MediaControl( vlm_t *vlm, vlm_media_t *media, const char *psz_id, ...@@ -1268,36 +1266,65 @@ int vlm_MediaControl( vlm_t *vlm, vlm_media_t *media, const char *psz_id,
if( !strcmp( psz_command, "seek" ) ) if( !strcmp( psz_command, "seek" ) )
{ {
float f_percentage;
if( psz_args ) if( psz_args )
{ {
f_percentage = i18n_atof( psz_args ); vlc_bool_t i_rel;
if( f_percentage >= 0.0 && f_percentage <= 100.0 ) float f_value = i18n_atof( psz_args );
if( psz_args[0] == '+' || psz_args[0] == '-' )
i_rel = VLC_TRUE;
else
i_rel = VLC_FALSE;
if( strstr( psz_args, "ms" ) )
{ {
var_SetFloat( p_instance->p_input, "position", /* milliseconds */
f_percentage / 100.0 ); int64_t i_msec = 1000 * (int64_t)atoi( psz_args );
return VLC_SUCCESS; if( i_rel )
{
var_SetTime( p_instance->p_input, "time-offset",
i_msec );
} }
else if( i_msec >= 0
&& i_msec < var_GetTime( p_instance->p_input, "length" ) )
{
var_SetTime( p_instance->p_input, "time",
i_msec );
} }
} }
else if( !strcmp( psz_command, "msecseek" ) ) else if( strchr( psz_args, 's' ) )
{ {
double d_msec; /* seconds */
int64_t i_time, i_current; int64_t i_sec = 1000000 * (int64_t)atoi( psz_args );
if( i_rel )
if( psz_args ) {
var_SetTime( p_instance->p_input, "time-offset",
i_sec );
}
else if( i_sec >= 0
&& i_sec < var_GetTime( p_instance->p_input, "length" ) )
{
var_SetTime( p_instance->p_input, "time",
i_sec );
}
}
else
{ {
d_msec = i18n_atof( psz_args ); /* percentage */
i_time = (int64_t)(d_msec * 1000); f_value /= 100.;
i_current = var_GetTime( p_instance->p_input, "length" ); if( i_rel )
if( i_time >= 0 && i_time <= i_current )
{ {
var_SetTime( p_instance->p_input, "time", i_time ); float f_orig = var_GetFloat( p_instance->p_input,
"position" );
f_value += f_orig;
}
if( f_value >= 0.0 && f_value <= 1.0 )
{
var_SetFloat( p_instance->p_input, "position",
f_value );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
} }
} }
}
else if( !strcmp( psz_command, "rewind" ) ) else if( !strcmp( psz_command, "rewind" ) )
{ {
float f_pos; float f_pos;
...@@ -2065,8 +2092,7 @@ static vlm_message_t *vlm_Help( vlm_t *vlm, char *psz_filter ) ...@@ -2065,8 +2092,7 @@ static vlm_message_t *vlm_Help( vlm_t *vlm, char *psz_filter )
MessageAddChild( "play" ); MessageAddChild( "play" );
MessageAddChild( "pause" ); MessageAddChild( "pause" );
MessageAddChild( "stop" ); MessageAddChild( "stop" );
MessageAddChild( "seek (percentage)" ); MessageAddChild( "seek [+-](percentage) | [+-](seconds)s | [+-](miliseconds)ms" );
MessageAddChild( "msecseek (time in milliseconds)" );
return message; return message;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment