Click here to Skip to main content
13,048,035 members (72,955 online)
Click here to Skip to main content
Add your own
alternative version


2 bookmarked
Posted 27 Oct 2012

Creating a Playlist Control

, 27 Oct 2012
Rate this:
Please Sign up or sign in to vote.
Resuable Playlist Control for Use with COM Media Player Objects Such as Window Media Player


A much more simple way to create and manage Playlists for COM Media Player Objects such as Window Media Player.


When I first attempted doing some Tutorials some time ago, One of the ones I was most excited to attempt the Windows Media Player Tutorial. I was annoyed at the difficultly to make a Playlist or Media Library to use with it. About a month or so ago I came up with this solution and forgot about it, then about a week ago while cleaning out my computer I came across the Source Code for this. So here it is.

Using the code

Here's the code to use to create the Playlist control.

Imports Microsoft.VisualBasic.FileIO.FileSystem
Public Class MainControl
    Property MediaFolderPath As String = Nothing
    Property SupportedExtentions As List(Of String)
    Property MediaFiles As List(Of String)
    Property MediaFileNames As List(Of String)
    Property SelectedMediaFilePath As String = Nothing
    Property SelectedMediaFriendlyName As String = Nothing
    Enum ListMode As Integer
        FileMode = 0
        NameMode = 1
    End Enum
    Public Sub Init(Optional ByVal FetchNames As Boolean = False)
            MediaFiles = New List(Of String)
            If IsNothing(SupportedExtentions) = False Then
                If FileIO.FileSystem.DirectoryExists(MediaFolderPath) = True Then
                    For Each file As String In GetFiles(MediaFolderPath, FileIO.SearchOption.SearchAllSubDirectories)
                        For Each Extention As String In SupportedExtentions
                            If file.EndsWith(Extention) = True Then
                                Exit For
                            End If
                End If
            End If
            If FetchNames = True Then
            End If
        Catch ex As Exception

        End Try
    End Sub
    Public Sub FetchMediaNames()
        If IsNothing(MediaFiles) = False Then
            MediaFileNames = New List(Of String)
            For Each MediaItem As String In MediaFiles
                Dim FriendlyName As String = GetFileInfo(MediaItem).Name.Replace(GetFileInfo(MediaItem).Extension, "")
        End If
    End Sub
    Public Sub PopulateList(ListForUse As ListMode)
        If ListForUse = ListMode.FileMode Then
            For Each item As String In MediaFiles
        ElseIf ListForUse = ListMode.NameMode Then
            For Each friendlyname As String In MediaFileNames
        End If
    End Sub
    Private Sub PlayistView_DoubleClick(sender As Object, e As EventArgs) Handles PlayistView.DoubleClick
        If IsNothing(PlayistView) = False Then
            SelectedMediaFilePath = MediaFiles(PlayistView.SelectedIndex)
            SelectedMediaFriendlyName = GetFileInfo(MediaFiles(PlayistView.SelectedIndex)).Name.Replace(GetFileInfo(MediaFiles(PlayistView.SelectedIndex)).Extension, "")
        End If
    End Sub
End Class



This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

United States United States
This member doesn't quite have enough reputation to be able to display their biography and homepage.

You may also be interested in...

Comments and Discussions

GeneralMy vote of 1 Pin
Manfred R. Bihy31-Oct-12 5:09
mvpManfred R. Bihy31-Oct-12 5:09 
GeneralRe: My vote of 1 Pin
rspercy653-Nov-12 16:11
memberrspercy653-Nov-12 16:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170713.1 | Last Updated 27 Oct 2012
Article Copyright 2012 by MattSparks
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid