Finding time in seconds of sample file.
I'm playing an .ogg music file as a sample. What I want to do is find its full duration and its current 'position' eg a 4 minute track - and display their value, in a alt val or a counter, etc. Then I need to be able to start a track from a value, for example 1.32, so the 'track' would start from there.
What is the best way to accomplish this? Also, would looping the sample file change the method in any way?
Re: Finding time in seconds of sample file.
There is an expression to get the duration of a sample. It returns a value in milliseconds, so you must convert it to minutes/seconds:
SampleDuration("Ambient Zombies")/1000.0 = Sample Duration in seconds.
Use the set sample position, and do the opposite calculation (x1000) to choose the right place to start it from.
Re: Finding time in seconds of sample file.
Thanks, this certainly pointed me in the right direction.
But I do have one 'problem' - the duration of the ogg is different in two places.
In vlc media player, it is 1 min 13.
In MMF2, the same file is 75.692 seconds, which is 1.261533333 minutes.
I've had a bit of a debug attempt, and whether I'm looping or not, changing the channel or sample position, nothing changes. It still shows it as 1.26 minutes. Another track I tried is also a bit longer than it is in the media player. Also, listening at the same time with the MMF2 app and the media player playing, they are perfectly in sync and start and end at the same time.
I'm just curious really - as I know what the duration MMF2 gives it I can work with that. I'm just wondering where the difference comes from.
Re: Finding time in seconds of sample file.
You do know there aren't 100 seconds in a minute? MMF2 is indeed correct. You need to convert that fraction of a minute (those decimals) into seconds.