Quantcast
Channel: naudio Work Item Rss Feed
Viewing all articles
Browse latest Browse all 738

Commented Unassigned: Mp3FileReader - ArgumentOutOfRangeException - Non-negative number required [16407]

$
0
0
Hi there,

Just starting out with NAudio, but very hopeful it will make my coding life easier once I get past this issue.

I'm working on a WPF application (.net framework 4.5) that just needs to play any given MP3 file.

I'm using the following code pulled from a StackOverflow example (but I've also tried different variations, all with the same result):

```
using (var ms = File.OpenRead(audioFilePath))
using (var rdr = new Mp3FileReader(ms)) // exception is thrown here
using (var wavStream = WaveFormatConversionStream.CreatePcmStream(rdr))
using (var baStream = new BlockAlignReductionStream(wavStream))
using (var waveOut = new WaveOut(WaveCallbackInfo.FunctionCallback()))
{
waveOut.Init(baStream);
waveOut.Play();
while (waveOut.PlaybackState == PlaybackState.Playing)
{
Thread.Sleep(100);
}
}
```

When the Mp3FileReader constructor is called, I get the ArgumentOutOfRangeException and "Non-negative number required" message.

Any suggestions are appreciated, and please let me know if more information is required.
Thanks,
Geoffrey
Comments: You are correct, sir. It was the file itself. Also, I've reverted back to the more recently-suggested code; what I posted was just my last attempt before posting my question. Thanks for your quick response!

Viewing all articles
Browse latest Browse all 738

Trending Articles



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