Page 1 of 1

Media Player PlayList with ListView control

Posted: Sun Feb 21, 2010 12:34 am
by tvs praveen
Hi, Now i want to make Media Player PlayList using ListView control

Also i want to display Media Duration, Media Name and File Path in separated columns for all the imported media files in ListView :D

Want to know how to set colors for media files in ListView?, I mean i want to make to display current playing video file in ListView in red color, And want to display pending video files in pink color, And want to display yellow color for already played videos for Media Player, Like in this screenshot of BlackMagic software

And want to know followings

1. How to make to add media files to ListView, I mean add 1 Button if click that button wants to open OpenFileDialog then after selecting media file(s) want to display in ListView

2. I want to make ListView imported media files to clear them, I mean add 1 Button if click that Button wants to clear all the media files in ListView

3. If click button wants to play all the media files from ListView, I mean add 1 Button and if click that Button wants to play all the songs one by one in Media Player from ListView

4. If click any media file from ListView wants to play it in Media PLayer

Like in this BlackMagic software PlayList screenshot

Image

Please help me :D

- Kindly :)

- Tvs Praveen wahooo;

Re: Media Player PlayList with ListView control

Posted: Sun Feb 21, 2010 4:58 am
by CodenStuff
Hello,

Ok this is how you can use a ListView in your application. I wont go into too much detail on how to do everything otherwise I would have made your application for you lol. Youve already made a media player and know how to get track/time information so it should be easy to change it to work with the listview.

The first thing you want to do is add a "ListView" control to your form and use these codes to do the different things that you will need.

You will need some columns in your listview that displays the name of the track, duration and things like that so use this code to create those:
Code: Select all
ListView1.Columns.Add("Track Name").Width = 200
        ListView1.Columns.Add("Track Duration").Width = 150
You can add more if you need them but that gives you the idea of how to it. Now to add your data to those columns you will need to use this code to first create a new ListViewItem:
Code: Select all
Dim Track As New ListViewItem
Then underneath that you add your data to the track name column like this:
Code: Select all
Track = ListView1.Items.Add("Track Title")
And you want to add the duration of the track into the next column so to do that we also add a subitem:
Code: Select all
Track.SubItems.Add("Length of track")
You will want to add that into your openfiledialog code when your loading all the files into the listview something like:
Code: Select all
 Dim Track As New ListViewItem
        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            For Each strFileName As String In OpenFileDialog1.FileNames
                Track = ListView1.Items.Add(strFileName)
                Track.SubItems.Add("Length of track")'PLACE YOUR CODE FOR GETTING DURATION IN HERE
            Next
        End If
And that would list all files into the listview aswell as there duration and anything other information you want. If for example you added a 3rd column called "Artist" and you wanted to show that information you would need to add another subitem to that code like this:
Code: Select all
 Dim Track As New ListViewItem
        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            For Each strFileName As String In OpenFileDialog1.FileNames
                Track = ListView1.Items.Add(strFileName)
                Track.SubItems.Add("Length of track")'PLACE YOUR CODE FOR GETTING DURATION IN HERE
                Track.SubItems.Add("Artist")'PLACE YOUR CODE FOR GETTING THE ARTIST IN HERE
            Next
        End If
You also asked about how to highlight a track(row) in the listview and to do that you can add this sub anywhere within your code:
Code: Select all
Public Sub HighlightTrack(ByVal TrackName As String, ByVal HighlightColor As System.Drawing.Color)
        Dim TrackList As ListViewItem
        TrackList = ListView1.FindItemWithText(TrackName, False, 0)
        If Not TrackList Is Nothing Then
            ListView1.Focus()
            TrackList.BackColor = HighlightColor
            TrackList.Selected = True
        End If
    End Sub
And then whenever you want to highlight a specific track (row) to indicate that its playing or in a playlist etc you can call it by using this code line:
Code: Select all
HighlightTrack("Track Name", Color.Gold)
The "Track Name" is the name of the track you want to highlight and the "Color.Gold" is the color you want to highlight it in. So if you wanted to highlight a track called "Bob the builder" in red you would use:
Code: Select all
HighlightTrack("Bob the builder", Color.Red)
That should definitely get you started ;)

Happy coding cooll;

Re: Media Player PlayList with ListView control

Posted: Mon Feb 22, 2010 4:38 am
by tvs praveen
CodenStuff wrote:
Hello,

Ok this is how you can use a ListView in your application. I wont go into too much detail on how to do everything otherwise I would have made your application for you lol. Youve already made a media player and know how to get track/time information so it should be easy to change it to work with the listview.

The first thing you want to do is add a "ListView" control to your form and use these codes to do the different things that you will need.

You will need some columns in your listview that displays the name of the track, duration and things like that so use this code to create those:
Code: Select all
ListView1.Columns.Add("Track Name").Width = 200
        ListView1.Columns.Add("Track Duration").Width = 150
You can add more if you need them but that gives you the idea of how to it. Now to add your data to those columns you will need to use this code to first create a new ListViewItem:
Code: Select all
Dim Track As New ListViewItem
Then underneath that you add your data to the track name column like this:
Code: Select all
Track = ListView1.Items.Add("Track Title")
And you want to add the duration of the track into the next column so to do that we also add a subitem:
Code: Select all
Track.SubItems.Add("Length of track")
You will want to add that into your openfiledialog code when your loading all the files into the listview something like:
Code: Select all
 Dim Track As New ListViewItem
        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            For Each strFileName As String In OpenFileDialog1.FileNames
                Track = ListView1.Items.Add(strFileName)
                Track.SubItems.Add("Length of track")'PLACE YOUR CODE FOR GETTING DURATION IN HERE
            Next
        End If
And that would list all files into the listview aswell as there duration and anything other information you want. If for example you added a 3rd column called "Artist" and you wanted to show that information you would need to add another subitem to that code like this:
Code: Select all
 Dim Track As New ListViewItem
        If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            For Each strFileName As String In OpenFileDialog1.FileNames
                Track = ListView1.Items.Add(strFileName)
                Track.SubItems.Add("Length of track")'PLACE YOUR CODE FOR GETTING DURATION IN HERE
                Track.SubItems.Add("Artist")'PLACE YOUR CODE FOR GETTING THE ARTIST IN HERE
            Next
        End If
You also asked about how to highlight a track(row) in the listview and to do that you can add this sub anywhere within your code:
Code: Select all
Public Sub HighlightTrack(ByVal TrackName As String, ByVal HighlightColor As System.Drawing.Color)
        Dim TrackList As ListViewItem
        TrackList = ListView1.FindItemWithText(TrackName, False, 0)
        If Not TrackList Is Nothing Then
            ListView1.Focus()
            TrackList.BackColor = HighlightColor
            TrackList.Selected = True
        End If
    End Sub
And then whenever you want to highlight a specific track (row) to indicate that its playing or in a playlist etc you can call it by using this code line:
Code: Select all
HighlightTrack("Track Name", Color.Gold)
The "Track Name" is the name of the track you want to highlight and the "Color.Gold" is the color you want to highlight it in. So if you wanted to highlight a track called "Bob the builder" in red you would use:
Code: Select all
HighlightTrack("Bob the builder", Color.Red)
That should definitely get you started ;)

Happy coding cooll;
Still i can`t figure it out Media Player features like how to add songs to ListView and to display Media Title, Media Total Duration Time, File Path, How to make a Button to play a song from ListView, How to make a Button to play all the songs from ListView

And to highlight rows with colors

You just given how to highlight rows with names, But i only asked these things to highlight in selected colors following below, But i don`t how to figure it out highlighting rows in selected colors

I mean i want to highlight still pending songs to play to highlight them in Color.Red

To highlight current playing song in Color.Green

To highlight already played songs in Color.Yellow

And really i don`t know to figure it out ListView PlayList, And i don`t know where to add codes and how to start with codes

You just give codes to display media information in separated columns i too like it, But still i can`t figure it out and i don`t how to start

I know well to make features and playlist with ListBox which already learned from your excellent tutorials XD

PLEASE HELP ME TO MAKE THESE FEATURED MEDIA PLAYER PLAYLIST WITH LISTVIEW ALSO TO DISPLAY MEDIA TITLE, TOTAL TIME DURATION, ARTIST, GENRE, FILE PATH IN SEPARATED COLUMNS ALSO TO HIGHLIGHT ROWS WITH SELECTED COLORS

AGAIN AND AGAIN PLEASE HELP ME TO MAKE MEDIA PLAYER WITH LISTVIEW PLAYLIST clapper;