Hello,
First of all - sorry for my English :)
I'm trying to write C# program which will be download some media file via HTTP and play it at the same time.
It will be something like YouTube flashplayer.
But I'm using DirectShowNet lib to render video/audio.
Here you may ask yourself why this guy doesn't use "
File source (URL)" filter instead of "
File Source (Async)" filter? I know it will be easier but I'd like to manage process of file downloading.
I have no problems with file downloading separately and with file rendering separately.
DirectShow can render file even if it wasn't completely downloaded. Actually you should worry only about "Start" of media file (I guess there are media info).
And the question at last:
I write a file using something like the following code (in separate thread):
Stream strLocal = new FileStream(sTempLocalFilePath,
FileMode.Append,
FileAccess.Write,
FileShare.Read,
downBuffer.Length,
FileOptions.Asynchronous)
while ((bytesSize = strResponse.Read(downBuffer, 0, downBuffer.Length)) > 0)
{
strLocal.Write(downBuffer, 0, bytesSize);
}
When I try to render the file I have an error - file is used by another process.
I close
Stream strLocal
,render file (it's playing) and then I'm trying to open
Stream strLocal
again but you know - file is used by another process.
How can I write to the file which is using by DirectShow?
PS: I've read the following articles but they didn't help me :-O :
- http://www.java2s.com/Tutorial/CSharp/0300__File-Directory-Stream/AsyncFileStream.htm
- http://www.codeproject.com/KB/threads/asyncFileIO.aspx
Thanks for any help.
--
Timur