• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

Stream error when loading from the camera

New Here ,
Nov 17, 2015 Nov 17, 2015

Copy link to clipboard

Copied

Hi,

I've had this bug for a very long time (across multiple SDK's). I have an app that uses the camera, but every 10-20th time I do it, I get a Stream Error and sometimes (not always) the program crashes after that. I get to the camera UI and I can take a picture, and when I get back to my app (and I try to load the media promise), it fails to do so. I have seen this behaviour on iOS, but I'm not sure if it happens on Android as well. I remember at some point I had some problems with the camera sending multiple COMPLETE-events, so maybe that is related somehow.

I have compared my code to sample code, and it seems like I do it in the same way. Does anyone else have this problem?

The following is some snippets of the code I'm using (I have ommitted some of the less important parts):

    private function launchCameraUI():void {
        if (cameraOpen)
            return;
      
        var cameraUI:CameraUI = new CameraUI();
        addCameraListeners(cameraUI);
      
        cameraOpen = true;
        cameraUI.launch(MediaType.IMAGE);
    }

/////////////////////////////////////////////////////////////////////////////////////////////////////

    private function onCameraUIComplete(e:MediaEvent):void {
            cameraOpen = false;
          
        try {
                var cameraUI:CameraUI = e.target as CameraUI;
                removeCameraListeners(cameraUI);
              
                mediaPromise = e.data;
                dataSource = mediaPromise.open();
            if (mediaPromise.isAsync) {
                    var eventSource:IEventDispatcher = dataSource as IEventDispatcher;
                  
                    eventSource.addEventListener(Event.COMPLETE, onMediaLoaded);
                }
            else {
                    readMediaData();
                }
            }
            catch (e:Error) {
                App.i.reportError("onCameraUIComplete", e.getStackTrace(), e.message);
                App.i.openMessageBox(Language.current.getText("Error") + " (2)", Language.current.getText("info program error"), Language.current.getText("Ok") );
            }
        }

/////////////////////////////////////////////////////////////////////////

            var mpLoader:Loader = new Loader();
        cameraImage = true;
            mpLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onMediaPromiseLoaded);
            mpLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onMediaPromiseLoadError); // THIS IS THE ERROR EVENT THAT I SOMETIMES GET
            mpLoader.loadFilePromise(mediaPromise);

/////////////////////////////////////////////////////////////////////////

I hope someone can see what I'm doing wrong.

Thanks in advance

Mark

TOPICS
Performance issues

Views

402

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines