1

I have a windows media player object embedded in my form and it's set to auto-play a video.
I want that video to loop forever, but can't figure out how!

Right-clicking the object in design view brings up settings and includes "Play count" but setting it to 0 won't work. It reverts to 1 as soon as the properties window is closed. Also it won't accept -1. The max setting is 999 which isn't enough as the video will only loop for a few hours.

This is how I am manipulating controls:

    wmpPlayer.Ctlcontrols.play()

    wmpPlayer.Ctlcontrols.pause()

    wmpPlayer.URL = ofdOpen.FileName 'Play

  ' This does NOT work to make repeat forever!...
  ' wmpPlayer.settings.playCount() = 0 
  • I've tried catching the 'PlayStateChanged' event like so:

    Private Sub wmpPlayer_PlayStateChange_1(sender As Object, e As AxWMPLib._WMPOCXEvents_PlayStateChangeEvent) Handles wmpPlayer.PlayStateChange
    If e.newState = 8 Then
        wmpPlayer.Ctlcontrols.play()
    End If
    '0 = Undefined
    '1 = Stopped (by User)
    '2 = Paused
    '3 = Playing
    '4 = Scan Forward
    '5 = Scan Backwards
    '6 = Buffering
    '7 = Waiting
    '8 = Media Ended
    '9 = Transitioning
    '10 = Ready
    '11 = Reconnecting
    '12 = Last
    End Sub 
    

But I'm not sure if this method always works. I left my program running overnight on two machines and this morning one was still running but the other had stopped somehow.

Scott Solmer
  • 3,871
  • 6
  • 44
  • 72

2 Answers2

5

I want that video to loop forever, but can't figure out how!

Just set the "Loop" mode property in settings to true:

wmpPlayer.settings.setMode("Loop", True)
Idle_Mind
  • 38,363
  • 3
  • 29
  • 40
  • I'll try it tomorrow, thanks. Hans commented a solution earlier that worked for me, but the answer he commented on has been deleted! Oh well. I'll try this, if it works than it's simpler so hopefully it will help others. – Scott Solmer Nov 15 '13 at 00:48
  • It worked in when I tested it earlier today. Hopefully it works for you as well... =) – Idle_Mind Nov 15 '13 at 02:33
  • Excellent, works like a charm. Thanks! I don't know why someone down-voted, this precious tid bit of information is not easy to find! – Scott Solmer Nov 15 '13 at 13:07
  • Does not work for me for some reason. It says there is an unexpected end to statement, yet when I remove the brackets it works somewhat, just cuts off in the middle of the second loop. – FudgeMuffins Apr 11 '16 at 12:13
0

Or try with excel vba

WindowsMediaPlayer1.settings.setMode "Loop", True
abdomohamed
  • 134
  • 1
  • 5