We help IT Professionals succeed at work.

Get current location of Windows Media Player control

Fritz41
Fritz41 used Ask the Experts™
on
I am trying to develop an .NET application with a Windows Media Player control embedded to play .MOV files. This works fine but I need to synchronize the current video position with other files containing data related to the video.

So I need to get the currentPosition property of the Media Player as the video plays. I tried putting a Timer control on the form and then gettting the player's currentPosition property inside the timer's tick event. But for some reason the timer event does not fire when the Media Player starts. (I checked this several times - if the player is not playing, the tick event fires, but if it is playing, no tick event!).

Can anyone explain this to me or suggest an alternative for me to sequentially get the currentPosition property of the Media Player in code. I am using Visual Studio 2008 with .NET 3.5.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
http://msdn.microsoft.com/en-us/library/dd562692(v=vs.85).aspx

for current position you can try something like :

Me.AxWindowsMediaPlayer1.Ctlcontrols.currentPosition

http://social.msdn.microsoft.com/Forums/en/vblanguage/thread/fbcaa9d8-4c56-49c5-a155-522374675c63

Author

Commented:
Thanks. I know that. My problem is how the get the currentposition sequentially. But I seemed to have solved this, it seems if I start the timer AFTER the video is started, then the tick event fires, but not if I start if just before the video is started.

Commented:
If you see my second link it involves a timer tick

Author

Commented:
Thanks disrupt. I actually stumbled across the solution myself but the information in your second link is quite complete and worth awarding points to. Thanks.

For others who experience problems with the Timer tick event and Windows Media Player, my finding is that tick events to NOT fire if you have.

sub StartVideo
Timer.Start
wmp.URL = "C:\Trash\myVideo.MOV"
end sub

But it DOES work if you have:

sub StartVideo
wmp.URL = "C:\Trash\myVideo.MOV"
Timer.Start
end sub

I hope this makes sense. I have no idea why this occurs.