By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,104 Members | 1,540 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,104 IT Pros & Developers. It's quick & easy.

Directsound

P: n/a
I created a simple program that should play a file chosen in the
OpenFileDialog:
For some reason the program fails to play any wav file I choose
the debugger breaks on the line: buffer=new
SecondaryBuffer(Path.(o.FileName),info,dsDevice); and says :An unhandled
exception of type 'System.ArgumentException' occurred in
microsoft.directx.directsound.dll

Additional information: Value does not fall within the expected range.

here is the code:
private Device dsDevice = null;
private SecondaryBuffer buffer=null;
private BufferDescription info=null;
private OpenFileDialog o;
public Form1()
{
InitializeComponent();
o=new OpenFileDialog();
dsDevice = new Device();
dsDevice.SetCooperativeLevel(this,CooperativeLevel .Normal);
info=new BufferDescription();
info.ControlFrequency=true;
info.ControlVolume=true;
info.StaticBuffer=true;
info.LocateInSoftware=true;
info.DeferLocation=true;
o.Filter= "Wave Files(*.wav)|*wav";
o.ShowDialog();
buffer=new SecondaryBuffer(Path.(o.FileName),info,dsDevice);
if(dsDevice!=null)
buffer.Play(0,BufferPlayFlags.Looping);
}
I don't know what can be the problem.
Thanks for your help
Nov 16 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.