libsaria: Added a get_progress() function to the audio namespace

This function is used to access how far into the song the current audio
position is.  The value is returned as a percentage of the total length
for easy use by the UI.
This commit is contained in:
Bryan Schumaker 2011-10-29 17:23:25 -04:00
parent 0da84e8151
commit 8987dddade
2 changed files with 12 additions and 0 deletions

View File

@ -20,6 +20,7 @@ namespace libsaria
/* Position related functions */
bool seek(int);
bool seek_to(double);
int get_progress();
/* Volume functions */
double get_volume();

View File

@ -57,4 +57,15 @@ namespace libsaria
return ret;
}
int audio::get_progress()
{
gint64 progress;
gint64 duration;
if (!get_position(progress))
return 0;
if (!get_duration(duration))
return 0;
return (progress * 100) / duration;
}
};