Im trying to read the length of an mp3 but the result isn’t correct. The code is in C#.

sound_file: is the path to the file I want to check.

FMOD.Sound sound = null;
FMOD.RESULT result = system.createStream(sound_file, FMOD.MODE.ACCURATETIME | FMOD.MODE.SOFTWARE | FMOD.MODE._2D | FMOD.MODE.OPENONLY, ref sound);

uint length = 0;
result = sound.getLength(ref length, FMOD.TIMEUNIT.MS);

float length_seconds = length / 1000f;

The method SoundManager.ERRCHECK(result); throws an exception if result != FMOD.RESULT.OK, but the result is always OK so it seems like it’s working. However the value of length_seconds is not the actual length of the song and the error seems to differ for different files.

Has anyone experienced this behavior before, and does anyone have ideas how to solve it?

  • You must to post comments
Showing 0 results
Your Answer

Please first to submit.