libsaria: Give the audio separate position() and duration() functions

The UI can use these functions to set up an accurate progress bar based
on the number of nanoseconds each returns.
This commit is contained in:
Bryan Schumaker 2011-11-01 22:47:04 -04:00
parent 0eff7df5c4
commit c75d832934
2 changed files with 16 additions and 6 deletions

View File

@ -1,6 +1,10 @@
#ifndef LIBSARIA_AUDIO_H
#define LIBSARIA_AUDIO_H
extern "C" {
#include <gst/gst.h>
}
#include <string>
using namespace std;
@ -20,7 +24,8 @@ namespace libsaria
/* Position related functions */
bool seek(int);
bool seek_to(double);
int get_progress();
gint64 duration();
gint64 position();
/* Volume functions */
double get_volume();

View File

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