Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7559789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:43:30+00:00 2026-05-30T12:43:30+00:00

ok i have question, i made this code to play axmediaplayer base on item

  • 0

ok i have question, i made this code to play axmediaplayer base on item listed on listbox.
first i make this code to make a list using opendialog :

 private string[] files, path;
 private void button1_Click(object sender, EventArgs e)
    {
        if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
        {
            files = openFileDialog1.SafeFileNames;
            path = openFileDialog1.FileNames;
            for (int i = 0; i < files.Length; i++) {
                listBox1.Items.Add(files[i]);
            }
        }
    }

and then it play the music when the listbox index changed (when the item on the list box cliked) using this code :

private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
    axWindowsMediaPlayer1.URL = path[listBox1.SelectedIndex];
}

it works fine, and then i want player to automove to the next song base on item on my listbox. with using events PlayStateChange, so i make this code

private void axWindowsMediaPlayer1_PlayStateChange(object sender, AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e)
{
    if (axWindowsMediaPlayer1.playState == WMPLib.WMPPlayState.wmppsMediaEnded) 
    {
         if(listBox1.SelectedIndex < files.Length - 1)
         {
            listBox1.SelectedIndex = listBox1.SelectedIndex + 1;
         }
    }
}

the selected index change, but the player doesn’t auto play the next song. i must click the play button manually in order to play the list. can anyone help me up?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T12:43:32+00:00Added an answer on May 30, 2026 at 12:43 pm

    ok i found it, the solution is to add timer before playing the next song.
    first im adding timer, that shoud be timer1. and then i change playstate event to something like this :

    private void axWindowsMediaPlayer1_PlayStateChange(object sender, axWMPLib._WMPOCXEvents_PlayStateChangeEvent e)
        {
            if (axWindowsMediaPlayer1.playState == WMPLib.WMPPlayState.wmppsMediaEnded)
            {
                timer1.Interval = 100;
                timer1.Enabled = true;               
            }            
         }
    

    then on the timer i adding tick event, the tick event is something like this :

     private void timer1_Tick(object sender, EventArgs e)
        {
            if (listBox1.SelectedIndex < files.Length - 1)
            {
                listBox1.SelectedIndex++;
                timer1.Enabled = false;
            }
            else
            {
                listBox1.SelectedIndex = 0;
                timer1.Enabled = false;
            }            
        }       
    

    now its work fine ^^

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

https://stackoverflow.com/a/64983/468251 - Hello, I have question about this code, how made that working with
Coming from this question , I have a wxComboCtrl with a custom popup made
This is my first post, so please be nice :) I have a question
I have just read this question: Could this code damage my processor? and this
I have a question on sockets. I have this code: while(bytes = recv(sClient, cClientMessage,
So, I have this code that hasn't been touched since '99, and was made
This is borrowed from another question I made on the site, but would have
I have a question : So i have this line of code(i got it
I made a similar question a few days ago, but now I have new
Question for YUI experts... I have a table and I've made each cell of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.