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:
Bryan Schumaker 2011-11-02 08:20:26 -04:00
parent 9236dcbb50
commit 0a216c38ce
2 changed files with 19 additions and 0 deletions

View File

@ -26,6 +26,7 @@ namespace libsaria
bool seek_to(double);
gint64 duration();
gint64 position();
string posstr();
/* Volume functions */
double get_volume();

View File

@ -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();
}
};