Как воспроизвести список дорожек с помощью NAudio на C#

#c# #naudio

#c# #naudio

Вопрос:

Я пытаюсь сделать проект для школы, включающий как c #, так и базы данных. По сути, это аудиоплеер, который локально извлекает дорожки из путей в базе данных SQL Server.

Мой вопрос в том, поскольку я не могу решить свою проблему самостоятельно, как я могу воспроизвести список песен?

Я использую WaveOutEvent объект с именем outputDevice и AudioFileReader .

Я попытался получить индекс списка и воспроизвести его, и он «работает», или лучше, отладка говорит, что PlaybackState часть outputDevice «воспроизводится», но на самом деле она не воспроизводит музыку.

Вот некоторый код:

Рабочая часть:

 if (songsQueue.Count != 0)
{
    //where nQueue is the position of the list
    DataGridViewRow row = (DataGridViewRow)songsQueue[nQueue];

    if (outputDevice == null)
    {
        outputDevice = new WaveOutEvent();
        outputDevice.PlaybackStopped  = OnPlaybackStopped;
    }

    if (audioReader == null)
    {
        string path = row.Cells[7].Value.ToString();
        audioReader = new AudioFileReader(Application.StartupPath   @path);
        outputDevice.Init(audioReader);
        lblArtist.Text = row.Cells[2].Value.ToString();
        lblTrack.Text = row.Cells[3].Value.ToString();
        outputDevice.Play();
    }
}
  

Часть, которая не работает:

 audioReader.Dispose();
outputDevice.Dispose();
DataGridViewRow row = (DataGridViewRow)songsQueue[nQueue   1];
string path = row.Cells[7].Value.ToString();
audioReader = new AudioFileReader(Application.StartupPath   @path);

outputDevice = new WaveOutEvent();
outputDevice.Init(audioReader);

lblArtist.Text = row.Cells[2].Value.ToString();
lblTrack.Text = row.Cells[3].Value.ToString();

outputDevice.Play();
  

Я бы ожидал, что он будет воспроизводиться, поскольку метки lblArtist и lblTrack меняются, и outputDevice говорится, что он воспроизводится.

Заранее спасибо всем за помощь! : D