title: wmpPlayer Repeat Forever
body: <p>I have a windows media player object embedded in my form and it's set to auto-play a video.<br>
  I want that video to loop forever, but can't figure out how!</p>
  
  <p>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.</p>
  
  <p>This is how I am manipulating controls:</p>
  
  <pre class="lang-vb prettyprint-override"><code>    wmpPlayer.Ctlcontrols.play()
  
      wmpPlayer.Ctlcontrols.pause()
  
      wmpPlayer.URL = ofdOpen.FileName 'Play
  
    ' This does NOT work to make repeat forever!...
    ' wmpPlayer.settings.playCount() = 0 
  </code></pre>
  
  <ul>
  <li><p>I've tried catching the 'PlayStateChanged' event like so:</p>
  
  <pre><code>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 
  </code></pre></li>
  </ul>
  
  <p>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. </p>