Quantcast
Channel: NAudio
Viewing all articles
Browse latest Browse all 5831

New Post: How to stop current playback and play another

$
0
0
I'm doing some QA tools for audio and it happended, that i started to use NAudio. So far, so nice, but i've one issue.

I'm displaying list of files in DataGridView with button for each of them to play it out. Button handler looks like this (right now, it's about to change i hope).
private void showFilesGrid_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if( showFilesGrid.Columns[e.ColumnIndex].Name == "fileAction")
            {
                string fullFileName = showFilesGrid.Rows[e.RowIndex].Cells["fullPathDataGridView"].Value.ToString();
                WaveStream outputStream = new WaveFileReader(fullFileName);
                WaveChannel32 volumeStream = new WaveChannel32(outputStream);
                WaveOutEvent player = new WaveOutEvent();
                player.Init(volumeStream);
                player.Play();

            }
        } 
What i need is to somehow stop playback of current file when user chooses to play another one. I'm pretty novice in c#, visual studio and this stuff, but good kick should help me to solve this problem :)

Viewing all articles
Browse latest Browse all 5831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>