Skip to content

callback_finished_sending event fired before URL request completes #2

@shanplourde

Description

@shanplourde

At this time, callback_finished_sending is firing before the HTTP response is received from the audio stream upload. As shown in the current implementation of Main.as, private function finalize_recording():void below, ExternalInterface.call() is invoked right after new URLLoader(req).

if(_var1 != '')
{
var req:URLRequest = new URLRequest(_var1);
req.contentType = 'application/octet-stream';
req.method = URLRequestMethod.POST;
req.data = recorder.output;

var loader:URLLoader = new URLLoader(req);
ExternalInterface.call("$.jRecorder.callback_finished_sending");

}

The issue is that new URLLoader(req) invokes an HTTP request, but does not block until the response is returned. Thus the JavaScript callback_finished_sending is invoked before the HTTP request completes. As I don't have a Flash IDE to build this project, and limited Flash knowledge, the only thing that I can do is suggest a fix similar to the following, based on the Adobe API reference at http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/URLLoader.html:

if(_var1 != '')
{
var req:URLRequest = new URLRequest();
req.addEventListener(Event.COMPLETE, postAudio_urlLoader_complete);
req.data = recorder.output;
req.contentType = 'application/octet-stream';
req.method = URLRequestMethod.POST;
req.load(_var1);

}

function postAudio_urlLoader_complete(evt:Event):void {
ExternalInterface.call("$.jRecorder.callback_finished_sending");
}

It would be great if someone or the author of this component integrate this change and validate that callback_finished_sending is invoked after urlLoader_complete() returns.

Thanks
Shan

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions