1

I have some words in an array and want to play some related files that are on a website's host.(The name of those files are as same as the string words in the array). I want to use a axWindowsMediaPlayer to play each audio. But when I use it in a foreach loop it only plays the last one, because there is not any interrupt in it. How may I fix this problem?

string[] fileNames = textBox2.Text.ToLower().Split();

foreach (string words in fileNames)
{
   axWindowsMediaPlayer1.URL = ("http://the website address/" + words + ".mp3");
}

I use Visual Studio 2010 (c#) windows application.

Javad-M
  • 456
  • 6
  • 22

1 Answers1

0

I have a Sample of Windows Media Player. I just Selected all the Files that i have to play , formed a Playlist dynamically and played. Please refer if this may give you an idea

 private void GetMediaFiles()
    {
        FilePath = Application.StartupPath + "\\Videos\\";
        FileCount = Directory.GetFiles(FilePath).Length;
        Files = Directory.GetFiles(FilePath);

        playlist = axWMPlayer.playlistCollection.newPlaylist("MyPlaylist");

        for (int Count = 0; Count < FileCount; Count++)
        {
            media = axWMPlayer.newMedia(Files[Count]);
            playlist.appendItem(media);
        }

        RunMedia();
    }

    private void RunMedia()
    {
        try 
        {
            if (playlist.count > 0)
            {
                axWMPlayer.BringToFront();
                axWMPlayer.currentPlaylist = playlist;
                axWMPlayer.Ctlcontrols.play();
            }
            else
            {
                pbDefaultImage.BringToFront();
            }
        }
SH7
  • 732
  • 7
  • 20