Hi,
I’m studying the minimad, in this function:
static
enum mad_flow output(void *data,
struct mad_header const *header,
struct mad_pcm *pcm)
{
….
}
1.How to get the total time of a mp3 file?
2.How to get the time stamp for player (not system time, it need return the position time stamp)?
Can somebody help me? Thanks a lot.
On Aug 10, 2005, at 8:02 PM, cnmmd wrote:
1.How to get the total time of a mp3 file?
See:
http://www.mars.org/mailman/public/mad-dev/2005-July/001159.html http://www.mars.org/mailman/public/mad-dev/2005-July/001164.html
2.How to get the time stamp for player (not system time, it need return the position time stamp)?
You need to accumulate the playing time as the stream is decoded. You can do this in your output callback with something like:
static mad_timer_t current_time;
mad_timer_add(¤t_time, header->duration);
To translate the current playing time into specific units, use something like:
long milliseconds;
milliseconds = mad_timer_count(current_time, MAD_UNITS_MILLISECONDS);
Or you can use a sprintf-style conversion:
char time_str[18];
mad_timer_string(current_time, time_str, " %02lu:%02u:%02u", MAD_UNITS_HOURS, 0, 0);