Calculate the duration of a song (Media Player)

The code below calculates the length of the track in minutes and seconds from the Windows Media Player properties (which just gives the result in seconds). lblPT is the label used to display the Current Position and total time of Song, in

mm:ss / mm:ss
current position / time remaining

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


wmp.CurrentPosition gives the location in seconds of the song
wmp.SelectionEnd gives the total seconds of the selected MP3 Song

You might also like...

Comments

Thom Ass Oles

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“An expert is a man who has made all the mistakes that can be made in a very narrow field” - Niels Bohr