locked
"The request is invalid in the current state" error by Windows.Media.Capture.MediaCapture.StopRecordAsync()

    Question

  • Windows.Media.Capture.MediaCapture.StopRecordAsync() works fine most of the time, but triggers the following exception once in a while:

    "The request is invalid in the current state"

    Could anyone shed some light on this?  I am asking this because I want to give some useful hints to the app user when this happens.  The app records video from a camera. 


    Hong

    Monday, October 27, 2014 2:50 PM

Answers

All replies

  • Hello Hong,

    The error you are reporting usually only occurs when the MediaCapture has already stopped the recording. Are you seeing the "Failed" or "exceeded" events being fired? Are you getting an error? I guess I need more context to really help you with this.

    -James


    Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Monday, October 27, 2014 10:46 PM
    Moderator
  • Thanks for the tips, James.

    The app does not have any handlers for "Failed" or "exceeded" with which I am not familiar.

    For the sake of debugging, I tried to run Windows.Media.Capture.MediaCapture.StopRecordAsync() twice consecutively with an interval of a few seconds, and the second stopping always generates the following exception:

    "The stream number provided was invalid. (Exception from HRESULT: 0xC00D36B3)".

    I am not sure what you meant by "Are you getting an error?".  The exception described in the original post is what I get. 


    Hong

    Tuesday, October 28, 2014 1:35 AM
  • Hello Hong,

    You should always handle the "Failed" and "exceeded" events of the MediaCapture element. These events will give you status information for the MediaCapture element. If there is a problem during recording the "Failed" event will let you know that something went wrong and tell you what happened. The "exceeded" event will tell you when you have been recording for too long and the capture was stopped.

    MediaCapture.Failed

    http://msdn.microsoft.com/en-us/library/windows/apps/xaml/windows.media.capture.mediacapture.failed.aspx

    MediaCapture.RecordLimitationExceeded

    http://msdn.microsoft.com/en-us/library/windows/apps/xaml/windows.media.capture.mediacapture.recordlimitationexceeded.aspx

    I hope this helps,

    James


    Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Wednesday, October 29, 2014 12:29 AM
    Moderator
  • This is very helpful.  Thanks, James.  

    I will find out whether the aforementioned exception is correlated with MediaCapture.Failed. 

    MediaCapture.RecordLimitationExceeded probably never happens with this app that records video usually for seconds, at most for 1 or 2 minutes.


    Hong

    Wednesday, October 29, 2014 2:14 AM