|
You have an instance of the StreamingPlayer class, correct?
StreamingPlayer stmPlyr = new StreamingPlayer();
private void btnStartStream_Click(object sender, EventArgs e)
{
PullAudioCallback cbk = new PullAudioCallback(someAudioCallBack);
stmPlyr.Play(cbk);
}
private void someAudioCallBack(IntPtr data, int count)
{
}
- Nick Parker My Blog | My Articles
|
|
|
|
|
Nick, thanks for the reply! However, I still have a slight problem.
The constructor for StreamingPlayer needs three arguments - owner, DirectSound playback device and waveformat.
How do I include these in the function call? They are set in the function definition, i.e.
public StreamingPlayer(Control owner, Device device, WaveFormat format)
{
m_Device = device;
if (m_Device == null)
{
m_Device = new Device();
m_Device.SetCooperativeLevel(owner, CooperativeLevel.Normal);
m_OwnsDevice = true;
}
BufferDescription desc = new BufferDescription(format);
desc.BufferBytes = format.AverageBytesPerSecond;
desc.ControlVolume = true;
desc.GlobalFocus = true;
m_Buffer = new SecondaryBuffer(desc, m_Device);
m_BufferBytes = m_Buffer.Caps.BufferBytes;
m_Timer = new System.Timers.Timer(BytesToMs(m_BufferBytes) / 6);
m_Timer.Enabled = false;
m_Timer.Elapsed += new System.Timers.ElapsedEventHandler(Timer_Elapsed);
}
|
|
|
|
|
Sorry, disregard that...that was a really dumb question. Been working on this too long...not thinking straight.
BUT:
PullAudioCallback is a delegate defined as
public delegate void PullAudioCallback(IntPtr data, int count);
When I instantiate a PullAudioCallback object,
PullAudioCallback cbk = new PullAudioCallback(...)
I need arguments for data and count. What should these be?
I tried digging through the source code but I don't see where he calls this function explicitly, though it is integral to the application.
|
|
|
|
|
crushinghellhammer wrote:
I need arguments for data and count. What should these be?
It's a delegate which means that it's instance has to represent that signature it defines. Take a look at my example, the example function matches that method signature. Does that make sense?
- Nick Parker My Blog | My Articles
|
|
|
|
|
I see now! Sorry if this is exasperating...I'm new to C# and sometimes reading other people's code (in this case Ianier's) is a little confusing.
My understanding of his intention in using PullAudioCallback is that the delegate is supposed to wait for count bytes to be copied to the data buffer which is an IntPtr before it plays these bytes.
What exactly is IntPtr...is it a pointer to a byte array? What would the contents of
"someAudioCallBack(IntPtr data, int count" be?
Thanks again!
|
|
|
|
|
|
If i have a FileSteam and open a BinaryReader on it the FileStream is Closed/Disposed when I close the Binaryreader - does it work the other way around? Does calling Close on the FileStream call Close/Dispose on the BinaryReader?
Rugby League: The Greatest Game Of All.
|
|
|
|
|
PaleyX wrote:
Does calling Close on the FileStream call Close/Dispose on the BinaryReader?
No, you should not do that. Internally, the BinaryReader uses a reference to the FileStream instance. Because the BinaryReader implements IDisposable , you can wrap the BinaryReader in a using statement so try/finally blocks are emited and the BinaryReader is cast to an IDisposable and the Dispose() method is called.
- Nick Parker My Blog | My Articles
|
|
|
|
|
i am student ,and i want to work on some telephony application
i know that the perfect subject is TAPI ,but there are some questions :-
1- can i use the TAPI in c# language ?
2- should i install some files or dll files that help to execute TAPI functionallity ?
3-couild i have an example in c# that shows me how exactly work with TAPI in c#?
finally ,forgive me for my bad english?
>
|
|
|
|
|
Wail A.Salem wrote:
can i use the TAPI in c# language ?
Yes, but you will have to P/Invoke your method calls because they are native. If you are unfamiliar with this process you can find more information here[^]. Take a look at the TAPI.H file to see what's available to you.
- Nick Parker My Blog | My Articles
|
|
|
|
|
Nick Parker wrote:
Yes, but you will have to P/Invoke your method calls because they are native. If you are unfamiliar with this process you can find more information here
[edit]
Probably better to make use of the work already done by Helen Warn[^]
Its a good lesson in Interop too.
Michael
CP Blog [^]
|
|
|
|
|
Michael P Butler wrote:
Probably better to make use of the work already done by Helen Warn[^]
I would agree that it would be extremely practical (in the business sense) to use the project Helen Warn has put together, however I took into consideration that he was a student and learning the process behind P/Invoke would be helpful in the long run.
- Nick Parker My Blog | My Articles
|
|
|
|
|
Nick Parker wrote:
however I took into consideration that he was a student and learning the process behind P/Invoke would be helpful in the long run.
Certainly. However, speaking from experience. TAPI can be hard enough to get to work, without having the extra overhead of learning P/Invoke too.
Michael
CP Blog [^]
|
|
|
|
|
Wail A.Salem wrote:
can i use the TAPI in c# language ?
Yes. You can use TAPI 3 via COM interop but it isn't 100% reliable. This article[^] is supposed to be a lot more reliable. I haven't used it personally as I already have my own TAPI 2 Com wrapper.
IMO, unless you really have a good reason to use C#. TAPI is a lot easier to use in C++.
Michael
CP Blog [^]
|
|
|
|
|
i want to write a rss reader program. but i'm a beginner and i dont know how to start. there're 2 problems for me now:
1. i dont know how to read .aspx files (for example http://www.gotdotnet.com/team/dbox/rss.aspx)
2. how can i display text from that file in form???
thanks!!!
|
|
|
|
|
Have a read of this[^]
It should tell you all you need to know.
Michael
CP Blog [^]
|
|
|
|
|
thanks...i'm trying to understand
|
|
|
|
|
|
Konstantin_progr wrote:
i want to write a rss reader program.
I'll assume you want to use C# as your language of choice, however you need to under that RSS isn't tied to a particular file format (i.e., .aspx file extensions). Take a look at RSS 2.0 Specification[^] to understand it's format. Once you understand the structure, you can write you own class to handle this, as others have already. CP has several articles here covering such tasks, I would suggest you take a look at them: RSS Reader[^] and RSS 2.0 Framework[^]. If you have a specific question related to displaying your data, please expand on your question.
- Nick Parker My Blog | My Articles
|
|
|
|
|
Hi all,
I have a windows form listview (in details mode) that I want to essentially fill on demand. Each item is moderately expensive to load and there may be 1000's of them in some cases. So my plan: fill it with place-holders (dummy listviewitem s) and then load the real items (derived from listviewitem ) as the user scrolls them into view.
Now the tricky bit: no "scroll" event on the listview . A little research here at codeproject suggests the thing to do is derive from listview and overide the WndProc method and handle the WM_VSCROLL message. All good so far.
My question: how can I tell how far it has scrolled? More directly: how can I tell which items will be visible to the user?
Thanks in advance,
Bill
ps: Is there an easier way to do this that I am missing? I can't be the only person who's tried this...
|
|
|
|
|
For getting scrollBar position, P/invoke GetScrollPos
[System.Runtime.InteropServices.DllImport("user32")]
public static extern int GetScrollPos(int hwnd, int nBar);
Regards,
Jay.
|
|
|
|
|
How can i make it that only double clicking the textbox object will enter
to the input prompt? (text input)
|
|
|
|
|
You need to add an event handler for the DoubleClick event.
textBox1.DoubleClick += new EventHandler(double_Click);
private void double_Click(object sender, EventArgs e)
{
}
- Nick Parker My Blog | My Articles
|
|
|
|
|
catching the double click doesnt help because I want prevent the prompt from
apearing inside the textbox when i single click it, do you know of a way to do that?
|
|
|
|
|
One way to achieve what it looks like you're going for is to default the text box's ReadOnly property to true, and set its TabStop property to false (just a style issue - not really necessary).
Then, as the previous poster suggested, create a handler for the DoubleClick event, wherein the ReadOnly property is set to false, enabling input to be entered in the text box.
Finally, create a handler for the Leave event (or Validated or...) that sets the control's ReadOnly property back to true.
Hope this helps.
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|