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.

4

2 回答 2

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)
于 2013-11-14T23:33:43.557 回答
0

Or try with excel vba

WindowsMediaPlayer1.settings.setMode "Loop", True
于 2022-02-03T15:23:19.890 回答