     import flash.utils.Timer;
     import org.hola.ZErr;
     import org.hola.Base64;
+    import org.hola.WorkerUtils;
+    import org.hola.HEvent;
     import org.mangui.hls.loader.FragmentLoader;
 
     public dynamic class JSURLStream extends URLStream {
         private var _connected : Boolean;
         private var _resource : ByteArray = new ByteArray();
+        private var _curr_data : Object;
         public var holaManaged:Boolean = false;
         public static var jsApiInited:Boolean = false;
         public static var reqCount:Number = 0;


        private function onOpen(event : Event) : void { _connected = true; }

        protected static function hola_onFragmentData(o:Object):void{
            var stream:JSURLStream;
            try {
                stream = reqs[o.req_id];
                if (!stream)
                    throw new Error('req_id not found '+o.req_id);
                if (o.error)
                {
                    delete reqs[o.req_id];
                    return stream.resourceLoadingError();
                }
                if (o.data)
                {
                    var data:ByteArray = Base64.decode_str(o.data);
                    data.position = 0;
                    if (stream._resource)
                    {
                        var prev:uint = stream._resource.position;
                        data.readBytes(stream._resource,
                            stream._resource.length);
                        stream._resource.position = prev;
                    }
                    else
                        stream._resource = data;
                    // XXX arik: get finalLength from js
                    var finalLength:uint = stream._resource.length;
                    stream.dispatchEvent(new ProgressEvent(
                        ProgressEvent.PROGRESS, false, false,
                        stream._resource.length, finalLength));
                }
                if (o.status)
                {
                    delete reqs[o.req_id];
                    // XXX arik: dispatch httpStatus/httpResponseStatus
                    stream.resourceLoadingSuccess();
                }
            } catch(err:Error){
                ZErr.log('Error in hola_onFragmentData', ''+err,
                    ''+err.getStackTrace());
                delete reqs[o.req_id];
                if (stream)
                    stream.resourceLoadingError();
                throw err;

            holaManaged = FragmentLoader.g_hls_mode;
            reqCount++;
            req_id = 'req'+reqCount;
            ZErr.log("load "+req_id);
            if (!holaManaged)
                return super.load(request);
            WorkerUtils.addEventListener(HEvent.WORKER_MESSAGE, onmsg);
            reqs[req_id] = this;
            _resource = new ByteArray();
            _trigger('requestFragment', {url: request.url, req_id: req_id});
