Controlling media player in VBA question

  • Thread starter Thread starter teepee
  • Start date Start date
T

teepee

I want to get media player to jump back 5 seconds with a VBA macro

I tried

Dim lastpos As Long
MP.CurrentPosition = lastpos - 5

but that didn't work. It just says:

run time error 380

currentposition must be -1.0 or greater than or equal to 0.0

Anyone know how it might be done?
 
Not a media player expert, but I would guess from the code you have given,
lastpos = 0. Therefore you are trying to set CurrentPosition = -5, which, as
the error message states, is invalid.
So you have to set the value of lastpos somewhere and check its value

lastpos=MP.<SomeProperty>
'code....
Const REWIND_SECONDS as long=5
if lastpos>REWIND_SECONDS then
MP.CurrentPosition = lastpos - REWIND_SECONDS
else
MP.CurrentPosition = 0
end if

Not sure what a CurrentPosition = -1 means, but check the docs.

NickHK
 
Not a media player expert, but I would guess from the code you have given,
lastpos = 0. Therefore you are trying to set CurrentPosition = -5, which, as
the error message states, is invalid.

Thanks - will try that
 
Const REWIND_SECONDS as long=5
if lastpos>REWIND_SECONDS then
MP.CurrentPosition = lastpos - REWIND_SECONDS
else
MP.CurrentPosition = 0
end if

That worked. Thanks v much
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top