Code: Select all
--- src/misc/vlm.c.orig Thu Nov 9 18:14:40 2006
+++ src/misc/vlm.c Tue Oct 31 18:39:28 2006
@@ -613,7 +613,8 @@
if( strcmp( ppsz_command[2], "play" ) &&
strcmp( ppsz_command[2], "stop" ) &&
strcmp( ppsz_command[2], "pause" ) &&
- strcmp( ppsz_command[2], "seek" ) )
+ strcmp( ppsz_command[2], "seek" ) &&
+ strcmp( ppsz_command[2], "msecseek" ) )
{
i_index++;
psz_instance = ppsz_command[2];
@@ -1274,6 +1275,23 @@
}
}
}
+ else if( !strcmp( psz_command, "msecseek" ) )
+ {
+ double d_msec;
+ vlc_value_t val, current;
+
+ if( psz_args )
+ {
+ d_msec = i18n_atof( psz_args );
+ val.i_time = (int64_t)(d_msec * 1000);
+ var_Get( p_instance->p_input, "length", ¤t );
+ if( val.i_time >= 0 && val.i_time <= current.i_time )
+ {
+ var_Set( p_instance->p_input, "time", val );
+ return VLC_SUCCESS;
+ }
+ }
+ }
else if( !strcmp( psz_command, "rewind" ) )
{
float f_pos;
@@ -2044,6 +2062,7 @@
MessageAddChild( "pause" );
MessageAddChild( "stop" );
MessageAddChild( "seek (percentage)" );
+ MessageAddChild( "msecseek (time in milliseconds)" );
return message;
}
Code: Select all
--- src/misc/vlm.c.orig Thu Nov 9 18:26:51 2006
+++ src/misc/vlm.c Wed Nov 1 13:51:46 2006
@@ -615,7 +615,8 @@
if( strcmp( ppsz_command[2], "play" ) &&
strcmp( ppsz_command[2], "stop" ) &&
strcmp( ppsz_command[2], "pause" ) &&
- strcmp( ppsz_command[2], "seek" ) )
+ strcmp( ppsz_command[2], "seek" ) &&
+ strcmp( ppsz_command[2], "msecseek" ) )
{
i_index++;
psz_instance = ppsz_command[2];
@@ -1276,6 +1277,23 @@
}
}
}
+ else if( !strcmp( psz_command, "msecseek" ) )
+ {
+ double d_msec;
+ vlc_value_t val, current;
+
+ if( psz_args )
+ {
+ d_msec = i18n_atof( psz_args );
+ val.i_time = (int64_t)(d_msec * 1000);
+ var_Get( p_instance->p_input, "length", ¤t );
+ if( val.i_time >= 0 && val.i_time <= current.i_time )
+ {
+ var_Set( p_instance->p_input, "time", val );
+ return VLC_SUCCESS;
+ }
+ }
+ }
else if( !strcmp( psz_command, "stop" ) )
{
TAB_REMOVE( media->i_instance, media->instance, p_instance );
@@ -2011,6 +2029,7 @@
MessageAddChild( "pause" );
MessageAddChild( "stop" );
MessageAddChild( "seek (percentage)" );
+ MessageAddChild( "msecseek (time in milliseconds)" );
return message;
}
Code: Select all
control media seek 0.23 -> behaves like before (can't break previous behavior)
control media seek +0.23 -> seek 23% forward
control media seek -0.23 -> seek 23% backwards
control media seek 123ms -> msecseek
same with +/-
control media seek 123s -> secseek
Code: Select all
--- src/misc/vlm.c.bak Mon Nov 20 10:49:47 2006
+++ src/misc/vlm.c Mon Nov 20 11:49:21 2006
@@ -51,12 +51,12 @@
/*****************************************************************************
* Local prototypes.
*****************************************************************************/
-static vlm_message_t *vlm_Show( vlm_t *, vlm_media_t *, vlm_schedule_t *, char * );
+static vlm_message_t *vlm_Show( vlm_t *, vlm_media_t *, vlm_schedule_t *, const char * );
static vlm_message_t *vlm_Help( vlm_t *, char * );
static vlm_media_instance_t *vlm_MediaInstanceSearch( vlm_t *, vlm_media_t *, const char * );
-static vlm_message_t *vlm_MessageNew( char *, const char *, ... );
+static vlm_message_t *vlm_MessageNew( const char *, const char *, ... );
static vlm_message_t *vlm_MessageAdd( vlm_message_t *, vlm_message_t * );
static vlm_schedule_t *vlm_ScheduleSearch( vlm_t *, const char * );
@@ -621,6 +621,12 @@
psz_instance = ppsz_command[2];
if( i_command < 4 ) goto syntax_error;
+
+ if( strcmp( ppsz_command[3], "play" ) &&
+ strcmp( ppsz_command[3], "stop" ) &&
+ strcmp( ppsz_command[3], "pause" ) &&
+ strcmp( ppsz_command[3], "seek" ) )
+ goto syntax_error;
}
psz_command = ppsz_command[i_index];
@@ -1263,16 +1269,57 @@
if( !strcmp( psz_command, "seek" ) )
{
vlc_value_t val;
- float f_percentage;
if( psz_args )
{
- f_percentage = i18n_atof( psz_args );
- if( f_percentage >= 0.0 && f_percentage <= 100.0 )
- {
- val.f_float = f_percentage / 100.0 ;
- var_Set( p_instance->p_input, "position", val );
- return VLC_SUCCESS;
+ vlc_bool_t i_rel;
+ 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" ) )
+ {
+ /* milliseconds */
+ int64_t i_msec = 1000 * (int64_t)atoi( psz_args );
+ 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( strchr( psz_args, 's' ) )
+ {
+ /* seconds */
+ int64_t i_sec = 1000000 * (int64_t)atoi( psz_args );
+ if( i_rel )
+ {
+ 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
+ {
+ /* percentage */
+ f_value /= 100.;
+ if( i_rel )
+ {
+ 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;
+ }
}
}
}
@@ -1315,7 +1362,7 @@
/*****************************************************************************
* Schedule handling
*****************************************************************************/
-static int64_t vlm_Date()
+static int64_t vlm_Date( void )
{
#ifdef WIN32
struct timeb tm;
@@ -1578,7 +1625,7 @@
/*****************************************************************************
* Message handling functions
*****************************************************************************/
-static vlm_message_t *vlm_MessageNew( char *psz_name,
+static vlm_message_t *vlm_MessageNew( const char *psz_name,
const char *psz_format, ... )
{
vlm_message_t *p_message;
@@ -1641,7 +1688,7 @@
* Misc utility functions
*****************************************************************************/
static vlm_message_t *vlm_Show( vlm_t *vlm, vlm_media_t *media,
- vlm_schedule_t *schedule, char *psz_filter )
+ vlm_schedule_t *schedule, const char *psz_filter )
{
if( media != NULL )
{
@@ -2010,7 +2057,7 @@
MessageAddChild( "play" );
MessageAddChild( "pause" );
MessageAddChild( "stop" );
- MessageAddChild( "seek (percentage)" );
+ MessageAddChild( "seek [+-](percentage) | [+-](seconds)s | [+-](milliseconds)ms" );
return message;
}
Users browsing this forum: No registered users and 0 guests