Determining the length of Midi/MPG's is surprisingly simple in Squeak.
For Midi's:
s _ MIDIFileReader scoreFromFileNamed: afile.
^(1.0 x s durationInTicks) / (2.0 x s ticksPerQuarterNote).
Here afile is of course, a path to a midi, and s is just a holder for its score.
This little snippet of code should be fairly self explanatory. One issue is that it does overestimate the length of the song a bit, so you may wish to adjust the static values more to your liking.
You might want to have a look at the MIDIFileReader and ScorePlayer
classes for more about this. In particular, the tempoOrRateChanged method in ScorePlayer might be of use.
update:
s _ ScorePlayer onScore: (MIDIFileReader scoreFromFileNamed: afile).
s jumpToTick: 0.
^((60.0 / (s tempo x s rate x s score ticksPerQuarterNote)) x (s durationInTicks)).