Well that’s dumb…
I found a problem with my media player control (of course). One of the things I wanted to do was have it report the duration of the media. However it seems that the Windows media player dll (wmp.dll) that it uses does not report that until the file is actually playing, which is pretty useless.
After a lot of Googling I found something that said if you put the media in a playlist it would work correctly. Tried it, still did not work. Then I found this code that does (so far anyway) seem to work:
Dim oMedia As IWMPMedia Set oMedia = wmp.newMedia("C:\MyStuff\mp303 Johnny B Goode.mp3") Dim dDummy As Double Dim dDuration As Integer dDummy = oMedia.duration wmp.currentMedia = oMedia dDuration = wmp.currentMedia.duration MsgBox ("Duration=" & dDuration)
For some reason doing a dummy query of the media duration against the media object makes it work later on when you query the player itself. Just seems a bit ‘daft’ to me. I mean, who the hell would figure that out (obviously someone did!) and why do it that way at all, why not just make it work like it should?
Anyway, I have updated the control source that is linked to in the earlier post to include this change.