简体   繁体   中英

Windows media player play states in C#

I´m beginner in C# coding. Especially, when it comes to use Wmp in C#. I work in visual studio 2017, on a project called "station information system" for a small, private railway in our country. The whole functionality of program I´ve done correctly, it works, so now I need to come up with an idea, how to make it playing. My program exports exact names of mp3 files into a hidden listbox. To generate patches I use this code:

axWindowsMediaPlayer1.URL = Path.Combine(Environment.CurrentDirectory, @"ZVUK\\", listBox2.SelectedItem.ToString());

It works, so I came to the other functionality I need from Wmp. When Wmp plays the full song, I need it to change the index in listbox and go to second song, then third and so on. I used this condition:

if (axWindowsMediaPlayer1.playState() = WMPLib.WMPPlayState.wmppsMediaEnded)

The part " playState() " is underlined and it shows me an error: " Non-invocable member "axWindowsMediaPlayer1.playState" cannot be used like a method. " I tried deleting brackets but it just underlined the whole part " axWindowsMediaPlayer1.playState ". Can someone help me?

Thank you very much.

You can use the following code to play the file one by one.

  private void button1_Click(object sender, EventArgs e)
        {
            SoundPlayer player = new SoundPlayer(@"2.wav");
            player.PlaySync();
            player = new SoundPlayer(@"\1.wav");
            player.PlaySync();
        }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM