temp.replace( pos, 2,
pVlcProc->getTimeVar().getAsStringCurrTime().c_str() );
}
+ while( (pos = temp.find( "$t" )) != UString::npos )
+ {
+ temp.replace( pos, 2,
+ pVlcProc->getTimeVar().getAsStringCurrTime(true).c_str() );
+ }
while( (pos = temp.find( "$L" )) != UString::npos )
{
temp.replace( pos, 2,
pVlcProc->getTimeVar().getAsStringTimeLeft().c_str() );
}
+ while( (pos = temp.find( "$l" )) != UString::npos )
+ {
+ temp.replace( pos, 2,
+ pVlcProc->getTimeVar().getAsStringTimeLeft(true).c_str() );
+ }
while( (pos = temp.find( "$D" )) != UString::npos )
{
temp.replace( pos, 2,
pVlcProc->getTimeVar().getAsStringDuration().c_str() );
}
+ while( (pos = temp.find( "$d" )) != UString::npos )
+ {
+ temp.replace( pos, 2,
+ pVlcProc->getTimeVar().getAsStringDuration(true).c_str() );
+ }
while( (pos = temp.find( "$V" )) != UString::npos )
{
temp.replace( pos, 2,
{
pVarManager->getHelpText().addObserver( this );
}
- if( m_text.find( "$T" ) != UString::npos )
+ if( m_text.find( "$T" ) != UString::npos ||
+ m_text.find( "$t" ) != UString::npos )
{
pVlcProc->getTimeVar().addObserver( this );
}
- if( m_text.find( "$L" ) != UString::npos )
+ if( m_text.find( "$L" ) != UString::npos ||
+ m_text.find( "$l" ) != UString::npos )
{
pVlcProc->getTimeVar().addObserver( this );
}
- if( m_text.find( "$D" ) != UString::npos )
+ if( m_text.find( "$D" ) != UString::npos ||
+ m_text.find( "$d" ) != UString::npos )
{
pVlcProc->getTimeVar().addObserver( this );
}
}
-const string StreamTime::getAsStringCurrTime() const
+const string StreamTime::getAsStringCurrTime( bool bShortFormat ) const
{
if( getIntf()->p_sys->p_input == NULL )
{
vlc_value_t time;
var_Get( getIntf()->p_sys->p_input, "time", &time );
- return formatTime( time.i_time / 1000000 );
+ return formatTime( time.i_time / 1000000, bShortFormat );
}
-const string StreamTime::getAsStringTimeLeft() const
+const string StreamTime::getAsStringTimeLeft( bool bShortFormat ) const
{
if( getIntf()->p_sys->p_input == NULL )
{
var_Get( getIntf()->p_sys->p_input, "time", &time );
var_Get( getIntf()->p_sys->p_input, "length", &duration );
- return formatTime( (duration.i_time - time.i_time) / 1000000 );
+ return formatTime( (duration.i_time - time.i_time) / 1000000,
+ bShortFormat );
}
-const string StreamTime::getAsStringDuration() const
+const string StreamTime::getAsStringDuration( bool bShortFormat ) const
{
if( getIntf()->p_sys->p_input == NULL )
{
vlc_value_t time;
var_Get( getIntf()->p_sys->p_input, "length", &time );
- return formatTime( time.i_time / 1000000 );
+ return formatTime( time.i_time / 1000000, bShortFormat );
}
-const string StreamTime::formatTime( int seconds ) const
+const string StreamTime::formatTime( int seconds, bool bShortFormat ) const
{
char *psz_time = new char[MSTRTIME_MAX_SIZE];
- snprintf( psz_time, MSTRTIME_MAX_SIZE, "%d:%02d:%02d",
- (int) (seconds / (60 * 60)),
- (int) (seconds / 60 % 60),
- (int) (seconds % 60) );
+ if( bShortFormat && (seconds < 60 * 60) )
+ {
+ snprintf( psz_time, MSTRTIME_MAX_SIZE, " %02d:%02d",
+ (int) (seconds / 60 % 60),
+ (int) (seconds % 60) );
+ }
+ else
+ {
+ snprintf( psz_time, MSTRTIME_MAX_SIZE, "%d:%02d:%02d",
+ (int) (seconds / (60 * 60)),
+ (int) (seconds / 60 % 60),
+ (int) (seconds % 60) );
+ }
string ret = psz_time;
delete[] psz_time;
/// Return a string containing a value from 0 to 100
virtual const string getAsStringPercent() const;
/// Return the current time formatted as a time display (h:mm:ss)
- virtual const string getAsStringCurrTime() const;
+ virtual const string getAsStringCurrTime( bool bShortFormat = false ) const;
/// Return the time left formatted as a time display (h:mm:ss)
- virtual const string getAsStringTimeLeft() const;
+ virtual const string getAsStringTimeLeft( bool bShortFormat = false ) const;
/// Return the duration formatted as a time display (h:mm:ss)
- virtual const string getAsStringDuration() const;
+ virtual const string getAsStringDuration( bool bShortFormat = false ) const;
private:
/// Convert a number of seconds into "h:mm:ss" format
- const string formatTime( int seconds ) const;
+ const string formatTime( int seconds, bool bShortFormat ) const;
};
#endif