0

I'm trying to play all videos from an specific folder in Visual Basic. I'm not sure what control I should use because WMP shows the controls and I want to reproduce the videos in a form without any controls. The other option may be MS TV Video Control.

My main issue right now is how to make the control play the videos from a folder without stopping and without showing the Play/Stop buttons.

I could do something like this:

For Each foundFile As String In My.Computer.FileSystem.GetFiles(
  My.Computer.FileSystem.SpecialDirectories.MyDocuments)
    listBox1.Items.Add(foundFile)
Next

But I'm not sure how to make the control play everything in the list.

Nathan Tuggy
  • 2,237
  • 27
  • 30
  • 38
Danny Sandi
  • 657
  • 7
  • 27

1 Answers1

3

This code demonstrates how to remove the controls from the WMP control and also how to create a looping playlist from a folder:

Public Class Form1

    Private Playlist As WMPLib.IWMPPlaylist

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
        AxWindowsMediaPlayer1.uiMode = "none"
        AxWindowsMediaPlayer1.settings.setMode("loop", True)
        Playlist = AxWindowsMediaPlayer1.newPlaylist("MyPlayList", "")
        AxWindowsMediaPlayer1.currentPlaylist = Playlist
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        If FolderBrowserDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            Button1.Enabled = False
            Playlist.clear()
            For Each video As String In System.IO.Directory.GetFiles(FolderBrowserDialog1.SelectedPath, "*.wmv")
                Playlist.appendItem(AxWindowsMediaPlayer1.newMedia(video))
            Next
            AxWindowsMediaPlayer1.Ctlcontrols.play()
        End If
    End Sub

End Class
Idle_Mind
  • 38,363
  • 3
  • 29
  • 40