libsaria: Return the current audio position as a string
This returns it in mm:ss format for easy use by the UI
This commit is contained in:
parent
9236dcbb50
commit
0a216c38ce
|
@ -26,6 +26,7 @@ namespace libsaria
|
|||
bool seek_to(double);
|
||||
gint64 duration();
|
||||
gint64 position();
|
||||
string posstr();
|
||||
|
||||
/* Volume functions */
|
||||
double get_volume();
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
|
||||
#include <sstream>
|
||||
using namespace std;
|
||||
|
||||
#include <libsaria/audio.h>
|
||||
#include "audio.h"
|
||||
|
||||
|
@ -73,4 +76,19 @@ namespace libsaria
|
|||
return position;
|
||||
}
|
||||
|
||||
string audio::posstr()
|
||||
{
|
||||
stringstream stream;
|
||||
int minutes, seconds, pos;
|
||||
|
||||
pos = position() / GST_SECOND;
|
||||
minutes = pos / 60;
|
||||
seconds = pos - (minutes * 60);
|
||||
stream << minutes << ":";
|
||||
if (seconds < 10)
|
||||
stream << "0";
|
||||
stream << seconds;
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue