Set Song/Video position using the Windows Media Player control

Hi EE,

I am using Visual Basic 6 and have a Windows Media Player control on my form. I want to be able to set the position of the current file playing through the code - not by clicking the progress bar. I can get the current position in two formats - raw (1.04356834) and string (03:28) - but I just can't work out how to set the position.

Thank you very much for your help,


Jackson
This is the code to get the raw position where WMP is the Windows Media Player control:
 
WMP.controls.currentPosition
 
This is the code to get the string position where WMP is the Windows Media Player control:
 
WMP.Controls.currentPositionString

Open in new window

LVL 1
sabrehagenAsked:
Who is Participating?
 
purquizConnect With a Mentor Commented:
Hi!

I just tested it with the WMP control, and the statement:

...
wmp.Controls.currentPosition = 30.04356834
...
works perfectly.

However, as the CurrentPositionString property is read-only, you cannot just jump to, for instance, the "03:21" position. If you want to do that, you may need to write a function to convert the "03:21" position to a Double, and then assign it to the currentposition property.

I hope that helped;

Pablo.
0
 
sabrehagenAuthor Commented:
Great, I'm such an idoit, I only tried with the string not the raw :(

To finish the question, how do you convert "03:21" to a double?
0
 
23637269Commented:
You can parse the string looking for Hr Min Sec and CDbl to get your position.
0
 
sabrehagenAuthor Commented:
Regrettably, I'm going to accept purquiz's answer, because even though it is right, I made the stupid mistake of only testing half the problem, the WRONG half :P If I hadn't given up, and tried to solve it myself, I'm sure I could have done it.

Thankyou anyway purquiz :)


Jackson
0
All Courses

From novice to tech pro — start learning today.