Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
How can I stream in a video in chunks to my windows form? I am trying to play a video from a stream but I want to stream it in chunks so it does not clog up the RAM. Any suggestions would be appriciated.
Here is some code I have tried:

C#
using (MemoryStream ms = new MemoryStream())
 {
      using (BinaryWriter br = new BinaryWriter(ms))
      {
           br.Write(8 + file.Length);
           br.Write(0x55665566);
           br.Write(file.Length);
           br.Write(file);
           ms.Seek(0, SeekOrigin.Begin);
           flashPlayer.OcxState = new AxHost.State(ms, 1, false, null);
      }
 }


but if the video larger than 1 gig the application freezes.
Posted
Updated 22-Feb-15 22:45pm
v2
Comments
Mehdi Gholam 22-Feb-15 2:24am    
Streaming video does this automatically.
Lance Andrew Coe 23-Feb-15 4:34am    
but if the stream is bigger than the RAM size (say a 2gig movie) the application freezes so I am trying to stream chunks at a time instead of loading the entire stream. sudo example:

load movie to memory stream;
MediaPlayer.PlayStream = memory stream;
Mehdi Gholam 23-Feb-15 4:36am    
That is not streaming.
Lance Andrew Coe 23-Feb-15 4:45am    
so how can I stream a video should I ask?
Mehdi Gholam 23-Feb-15 4:50am    
Google is your friend : streaming video c#

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900