Results 1 to 5 of 5

Thread: Media Player help!!

  1. #1

    Thread Starter
    Member yacky's Avatar
    Join Date
    Nov 2009
    Posts
    38

    Media Player help!!

    I'm making my Media Player in VB2008.
    I got Listbox1 as playlist.
    Buttons play and stop works, but buttons next and previous don't.
    What code i need to put for them?

    Thanks!

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Media Player help!!

    what does the code for the play button look like? If it is working, then isn't it playing the first item in the listbox1 when you click play?

    I would imagine the next and previous buttons would do the same thing, just grabbing the item before or after the current selected item in the listbox, and playing that.

  3. #3

    Thread Starter
    Member yacky's Avatar
    Join Date
    Nov 2009
    Posts
    38

    Re: Media Player help!!

    Code:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            AxWindowsMediaPlayer1.URL = ListBox1.SelectedItem
        End Sub

  4. #4
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Media Player help!!

    So for the play previous you would want to first make sure the first item is not playing (which means there is no previous item to play) and then get the item in the listbox that is before the currently selected item:

    Code:
            If listbox1.SelectedIndex > 0 Then
                AxWindowsMediaPlayer1.URL = listbox1.Items(listbox1.SelectedIndex - 1).ToString()
            Else
                'FIRST ITEM IS PLAYING, CANT PLAY PREVIOUS
            End If
    and to play next you want to do the opposite, and make sure you aren't on the last item which would prevent you from playing the next item if you are already on the last one.

    Code:
            If (listbox1.SelectedIndex + 1) <> listbox1.Items.Count Then
                AxWindowsMediaPlayer1.URL = listbox1.Items(listbox1.SelectedIndex + 1).ToString()
            Else
                'LAST ITEM IS PLAYING, CANT PLAY NEXT
            End If

  5. #5

    Thread Starter
    Member yacky's Avatar
    Join Date
    Nov 2009
    Posts
    38

    Re: Media Player help!!

    Thank you!

    It works!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width