views:

221

answers:

1

This is a VB6 question.

How does Windows Media Player compute duration? Is it possible to detect corrupt media files and do not compute duration on these? I sometimes get duration = 0, why does that happen?

Thanks :)

A: 

size_in_bytes / bitrate = length_in_seconds.

for wmp you can use

lblPlayTime.Caption = wmp.CurrentPosition \ 60 & ":" & Format(Int(wmp.CurrentPosition Mod 60), "00") & " / " & wmp.SelectionEnd \ 60 & ":" & Format(Int(wmp.SelectionEnd Mod 60), "00")

There is some great information here http://www.codeproject.com/KB/audio-video/mpegaudioinfo.aspx

Variable bitrates can sometimes cause the duration to be wonky in WMP (and others). I wouldn't count on it to be a hard and fast rule for corrupt files.

Robert French
Is it possible that the problem can be caused by the fact that i use a WMP v6.4 and the client mainly uses v11?
greendaale
if your using the above formula it shouldn't matter which version of the control your using, my understanding is that the Windows Media Player control (windows\system32\wmp.dll) is updated along with Windows Media Player ... so why not just install the latest WMP and use the same version as the client? this would eliminate the possibility of the control version being a reason.I still suspect that the problem your facing is due to a variable bitrate file being loaded ... the duration can't be properly determined until the whole file has been loaded. Hope that Helps :-)
Robert French