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:
parent
0eff7df5c4
commit
c75d832934
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue