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:
parent
0da84e8151
commit
8987dddade
|
@ -20,6 +20,7 @@ namespace libsaria
|
|||
/* Position related functions */
|
||||
bool seek(int);
|
||||
bool seek_to(double);
|
||||
int get_progress();
|
||||
|
||||
/* Volume functions */
|
||||
double get_volume();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue