2014-04-25 124 views

回答

1

希望能夠幫助任何正在困難地使用NAudio的人。

//Create Output Stream with Data from Audio File/Network Stream 
WaveOutputStream outputStream = new MediaFoundationReader("Path to File"); 
//Create Volume Stream to control volume of output 
//ex: volumeStream.Volume = 0.5f; Float between 0 & 1 
WaveChannel32 volumeStream = new WaveChannel32(outputStream); 
//Create WaveOutEvent since it works in Background and UI Threads 
WaveOutEvent player = new WaveOutEvent(); 
//Init Player with Configured Volume Stream 
player.Init(volumeStream); 
player.Play(); 

這個代碼可以播放任何音頻文件MediaFoundationReader支持(MP3,AAC,WAV等),以及這些編解碼器的網絡流。要在播放器,outputStream和volumeStream上重複使用上面的播放器調用Dispose(),然後將其設置爲null。

+0

MediaFoundation不包含FLAC解碼器。你可以安裝一個,但... –