This project has moved and is read-only. For the latest updates, please go here.

Stopping does not always work


Great library!

However a small fix might help... you might consider checking in OnGetResponse if you are still processing the right Uri and if _streamActive is still true. Sometimes when calling Play(Uri1) then Stop the Play(Uri2) there a 'mixed' stream displayed (as the Uri1 didn't have a chance to bail out from OnGetResponse and in between Play(Uri2) has set the flag back to true.

I hope I am not talking nonsense :)

PS: Consider also creating a smart NuGet package. Will make your library the 'defacto' one for decoding mjpeg :)


Cruachan wrote Jan 31, 2014 at 10:30 PM

Hey there,

I was using this code (by the way, thanks a ton!) and I noticed the same issue. I'm writing a webcam controller and noticed that when I stopped the stream, that the video from the camera kept sending.

I was able to fix it by simply adding the following line to the MjpegDecoder.cs file on line ~192:
This went (for me in the WP8 code) right before the lines you see stating:
This stopped the stream just fine. The 'req' reference came from above where the HttpWebRequest was created in the method 'ParseStream'... then, in the 'OnGetResponse' method, its hydrated in line ~128 as:
HttpWebRequest req = (HttpWebRequest)asyncResult.AsyncState;
After the while loop (while (_streamactive)) completes, you simply need to abort the request.

Hopefully this helps, someone may have already solved this, so sorry for the redundancy.