}
-const string StreamTime::getAsStringPercent() const
+string StreamTime::getAsStringPercent() const
{
int value = (int)(100. * get());
// 0 <= value <= 100, so we need 4 chars
}
-const string StreamTime::getAsStringCurrTime( bool bShortFormat ) const
+string StreamTime::formatTime( int seconds, bool bShortFormat ) const
+{
+ char psz_time[MSTRTIME_MAX_SIZE];
+ 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) );
+ }
+ return string(psz_time);
+}
+
+
+string StreamTime::getAsStringCurrTime( bool bShortFormat ) const
{
if( !havePosition() )
return "-:--:--";
}
-const string StreamTime::getAsStringTimeLeft( bool bShortFormat ) const
+string StreamTime::getAsStringTimeLeft( bool bShortFormat ) const
{
if( !havePosition() )
return "-:--:--";
}
-const string StreamTime::getAsStringDuration( bool bShortFormat ) const
+string StreamTime::getAsStringDuration( bool bShortFormat ) const
{
if( !havePosition() )
return "-:--:--";
mtime_t time = var_GetTime( getIntf()->p_sys->p_input, "length" );
return formatTime( time / 1000000, bShortFormat );
}
-
-
-const string StreamTime::formatTime( int seconds, bool bShortFormat ) const
-{
- char psz_time[MSTRTIME_MAX_SIZE];
- 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) );
- }
- return string(psz_time);
-}
virtual void set( float percentage ) { set( percentage, true ); }
/// Return a string containing a value from 0 to 100
- virtual const string getAsStringPercent() const;
+ virtual string getAsStringPercent() const;
/// Return the current time formatted as a time display (h:mm:ss)
- virtual const string getAsStringCurrTime( bool bShortFormat = false ) const;
+ virtual string getAsStringCurrTime( bool bShortFormat = false ) const;
/// Return the time left formatted as a time display (h:mm:ss)
- virtual const string getAsStringTimeLeft( bool bShortFormat = false ) const;
+ virtual string getAsStringTimeLeft( bool bShortFormat = false ) const;
/// Return the duration formatted as a time display (h:mm:ss)
- virtual const string getAsStringDuration( bool bShortFormat = false ) const;
+ virtual string getAsStringDuration( bool bShortFormat = false ) const;
private:
/// Convert a number of seconds into "h:mm:ss" format
- const string formatTime( int seconds, bool bShortFormat ) const;
+ string formatTime( int seconds, bool bShortFormat ) const;
/// Return true when there is a non-null input and its position is not 0.0.
bool havePosition() const;
};