Skip to content
WJunction - Webmaster Forum

Play selected listbox item

Status
Not open for further replies.
PHP:
 private void axWindowsMediaPlayer1_Enter(object sender, EventArgs e)
        {
            
            String playname = listBox1.SelectedItem.ToString();
            richTextBox3.Text = playname;
            axWindowsMediaPlayer1.URL = playname;
            axWindowsMediaPlayer1.Ctlcontrols.play();
            axWindowsMediaPlayer1.Ctlcontrols.pause();
            axWindowsMediaPlayer1.Ctlcontrols.stop();
            axWindowsMediaPlayer1.Ctlcontrols.next();

        }
I sometimes get error in between something to use new function for extracting string.
How to use that function ?
How to do this - If I double click a listbox item, WMP starts playing it.


Another thing is when I select a song from listbox and click play it plays, but the play button looks inactive at default though everything works and plays correctly.
 

4 comments

PHP:
if (listBox1.SelectedItem != null)
{
    richTextBox3.Text = axWindowsMediaPlayer1.URL = (string)listBox1.SelectedItem;
}

I doubt you're using the best event for this situation.
 
I'll try that out. I guess that error occurs when sometimes no item is there to be selected.

See, what my app does.
It gets source of a site and extract the mp3 URL's and lists them on text box.
My problem is when I type a song name and hit enter , the app gets out of control i.e. looks like it has hanged but it actually repeats the above process to list the songs, how to fix that ?

Reply this here. made a separate thread for listing all my problems about this app.
http://www.wjunction.com/showthread.php?t=39593
 
You'll need to learn what threads are and how to use them. Threads allow you to do multiple things at ones.
 
Status
Not open for further replies.

About the author

P
Active Member · Joined
Webmastering
1,817
Messages
149
Reactions
63
Points

Advertise on WJunction

Reach 1000's of webmasters, hosts & affiliates. Banner & sponsored-thread slots available.

Contact us
Back
Top Bottom