|
-
May 30th, 2008, 08:11 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Little bit of math and VB6
Hey folks.
Let me set my project up for you, I have one Windows Media Player component, and 3 text boxes.
In one text box I have coming from WMP the updating value of this output:
WindowsMediaPlayer1.Controls.currentPositionString
That shows the position of the currently playing clip in this format: “00:00”
The next text box I have shows the total duration of the clip:
WindowsMediaPlayer1.currentMedia.durationString
Which as well shows the duration of the clip in the “00:00” format.
I have a third text box that I would like to show how much time is remaining in the clip.
For example, I would like to be able to have something like:
WindowsMediaPlayer1.currentMedia.durationString (subtract) WindowsMediaPlayer1.Controls.currentPositionString
That would take the total duration of the video, and subtract the current position giving the total time remaining. However, I cannot get this to display, does anyone have any suggestions on how I would get this to work?
Thanks in advance!
-
May 30th, 2008, 09:56 PM
#2
Re: Little bit of math and VB6
vb Code:
Private Sub tmrShowTime()
txtDuration.Text = SecondsToTime(wmp.currentMedia.duration)
txtPosition.Text = SecondsToTime(wmp.Controls.currentPosition)
txtRemaining.Text = SecondsToTime(wmp.currentMedia.duration - wmp.Controls.currentPosition)
End Sub
Public Function SecondsToTime(ByVal plngSeconds As Long) As String
Dim lngMinutes As Long
Dim lngSeconds As Long
lngMinutes = plngSeconds \ 60
lngSeconds = plngSeconds Mod 60
SecondsToTime = lngMinutes & ":" & Format(lngSeconds, "00")
End Function
You say you want the time displayed in "00:00" format, but do you really want a leading zero? The above code assumes you don't. If you do, change the last line in the SecondsToTime() function to this:
SecondsToTime = Format(lngMinutes, "00") & ":" & Format(lngSeconds, "00")
Last edited by Ellis Dee; May 30th, 2008 at 10:04 PM.
-
Jun 13th, 2008, 01:56 PM
#3
Thread Starter
Hyperactive Member
Re: Little bit of math and VB6
Great! Thank you very much.
-
Jun 13th, 2008, 07:30 PM
#4
Re: Little bit of math and VB6
Now that we've helped you, you can help us by pulling down the Thread Tools menu and clicking the Mark Thread Resolved button which will let everyone know that you have your answer. Also if someone has been particularly helpful you have the ability to affect a their forum "reputation" by rating their post.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|