Re: Help:How to get the time stamp for player (not system time, it need return the position time stamp)
Rob Leslie <[email protected]> Wed, 10 Aug 2005 22:53:42 -0700
| Newsgroups | gmane.comp.audio.mad.devel |
|---|---|
| Message-ID | <[email protected]> |
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); -- Rob Leslie [email protected]