//dodanie nazw piosenek do gramatyki systemu rozpoznawania, zczytujac nazwy piosenek z pliku, ktory najpierw zostaje stworzony
        private void addSongNamesTotheDictionary(Choices choices_, string LINK)
        {
            Process getSongNamesProcess = new Process();
            Process clearFile           = new Process();

            try
            {
                clearFile.StartInfo.FileName  = "cmd.exe";
                clearFile.StartInfo.Arguments = "/c TYPE nul > " + filePath;
                clearFile.Start();

                getSongNamesProcess.StartInfo.FileName  = "cmd.exe";
                getSongNamesProcess.StartInfo.Arguments = "/c dir /b " + LINK + " >> songNames.txt";
                getSongNamesProcess.Start();
            }
            catch
            {
                MessageBox.Show("The file couldn't have been created");
            }

            WMPLib.IWMPControls3 controls = (WMPLib.IWMPControls3)wmplayer.Ctlcontrols;
            controls.play();

            WMPLib.IWMPPlaylist playlist = wmplayer.playlistCollection.newPlaylist("myplaylist");

            try
            {
                using (StreamReader sr = File.OpenText(filePath))
                {
                    string line = null;
                    while ((line = sr.ReadLine()) != null)
                    {
                        media = wmplayer.newMedia(LINK + @"\" + line);
                        line  = line.Substring(0, line.Length - 4);
                        listBox1.Items.Add(line);
                        playlist.appendItem(media);
                        choices_.Add("Katherine play " + line);
                    }
                    wmplayer.currentPlaylist = playlist;
                    wmplayer.Ctlcontrols.stop();
                }
            }
            catch
            {
                MessageBox.Show("STREAMREADER FAILED ;___;");
            }
        }
Пример #2
0
        private void btnPlay_Click(object sender, EventArgs e)
        {
            // Check first to be sure the operation is valid.
            if (mediaP_controls.get_isAvailable("play"))
            {
                mediaP_controls.play();
            }

            else if (songs.Count > 0)
            {
                mediaP.URL = songs[0].ToString();
                string tempItem = songs[0].ToString();
                songs.RemoveAt(0);
                songs.Add(new Song(tempItem));
                updateTxt();
            }
        }