ofSoundPlayer length

HI all, is there a way to get ofSoundPlayer sound file lengths.

no functions for it it seems. tried setPos(1.0) then getPosMS() but getPos won’t work unless sound file is playing and I need to get values on load.

anyone have a good way to do this?

1 Like

okay so setpos has to be called after play and a pos of 1 loops back to start. this sucks but works:

int ms = soundStart.getPositionMS();
printf(“SOUND LENGTH: %i\n\n”, ms);



I was in the process, nearly 8 years after your post, of experimenting to find a way to do this, and not finding it terribly easy.

I had tried almost exactly the same thing, only passing in 1.0f for the position.

However, in OF 0.11.0, it [EDIT] wasn’t seeming to work - it turned out to be some other problem with my code, though. Now this method is working for me, though it is still awkward.

Hopefully, someone will soon reply that there is now a better way to learn the length of an ofSoundPlayer?