|
-
Nov 16th, 2009, 11:44 AM
#1
Thread Starter
Member
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!
-
Nov 16th, 2009, 12:02 PM
#2
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.
-
Nov 16th, 2009, 12:17 PM
#3
Thread Starter
Member
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
-
Nov 16th, 2009, 12:34 PM
#4
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
-
Nov 16th, 2009, 05:59 PM
#5
Thread Starter
Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|