Windows Media Player

How do I Display the "Status Bar" Info into a textbox?

My form uses the Windows Media Player to Play an .mp3 file. I would like for it to display the Song Length/Time Remaining in a textbox.

To do this i suppose i could use a timer to refresh the Time Remaining part of it.

But i am lost as far as getting the Info in the first place.
kkoserAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

kkoserAuthor Commented:
bumped up the points.
0
mcriderCommented:
Try this:

Private Sub Form_Load()
    Timer1.Interval = 500
    Timer1.Enabled = False
End Sub
Private Sub MediaPlayer1_PlayStateChange(ByVal OldState As Long, ByVal NewState As Long)
Select Case NewState
    Case 2 ' PLAYING
        Timer1.Enabled = True
    Case 0 'STOPPED
        Timer1.Enabled = False
    Case Else
        Debug.Print NewState
End Select
End Sub
Private Sub Timer1_Timer()
    With MediaPlayer1
        Label1.Caption = CStr(Fix(.CurrentPosition)) & "/" & CStr(Fix(.Duration))
        If .CurrentPosition = .Duration Then Timer1.Enabled = False
    End With
End Sub



Cheers!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kkoserAuthor Commented:
Thanx a lot. it works good. But, How do i get it to display the time instead of a count? i.e., a 4:21 minutes long song displays as 261.

0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

mcriderCommented:
if you divide 261 by 60, you get 4.35 minutes... Just takes alittle division and formatting.

Understand?


Cheers!

0
kkoserAuthor Commented:
I understand the division part of the issue.


i used this:

 Label1.Caption = CStr(Fix(.CurrentPosition / 60)) & "/" &
                      CStr(Fix(.Duration / 60))

This won't display anything after the whole numbers.( i.e. (4.35) shows as (4)).

Although 261 divided by 60 = 4.35,
the duration for a 4.21 mp3 shows as 261. I wonder why that is?


However, I don't know how to format it to display the same as windows media player.   i.e. 00:00/00:00.

I guess this is what i was looking for.
0
mcriderCommented:
In the formula, Fix() returns a whole number.  Remove the Fix() portions and you will get the decimal notation.


Cheers!
0
mcriderCommented:
To display a time format, you could use the following function:

Function TimeFormat(lValue As Long) As String
    Dim lMin As Long
    Dim lSec As Long
    lMin = Fix(lValue / 60)
    lSec = lValue - (lMin * 60)
    TimeFormat = Format(lMin, "00:") + Format(lSec, "00")
End Function


Then do:

Label1.Caption = TimeFormat(.CurrentPosition) & "/" & TimeFormat(.Duration)


Cheers!

0
kkoserAuthor Commented:
Sorry for not responding so quickly. Kids with the flu...

This works absolutely awesome!

Thanx a lot.

0
kkoserAuthor Commented:
One more thing,

I have another question out there (Q.10223451). You had answered it but i had rejected it because i needed more elaboration. Since then, the problem has been resolved and no one has answered it. Could you answer the question so i can "Clean-Up" my mess?

Thanx in advance.

 
0
mcriderCommented:
You're quite welcome!  Glad I could help... (I posted on the other question, Waiting for you to grade it...)


Cheers!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.