         }
 
         private static function hola_hls_get_bitrate(): Number
-	{
-   	    return _hls.loadLevel<_hls.levels.length ? _hls.levels[_hls.loadLevel].bitrate : 0;
-	}
+        {
+            return _hls.loadLevel<_hls.levels.length ? _hls.levels[_hls.loadLevel].bitrate : 0;
+        }
 
         private static function hola_hls_get_level(): String
-	{
+        {
             return _hls.loadLevel<_hls.levels.length ? _hls.levels[_hls.loadLevel].url : undefined;
         }
 
-        private static function hola_setBandwidth(bandwidth:Number):void{
+        private static function hola_setBandwidth(bandwidth: Number): void
+        {
             _bandwidth = bandwidth;
         }
     }

            _state = e.state;
        }

	private static function on_level_loaded(e: HLSEvent): void
	{
            JSAPI.postMessage('flashls.'+e.type, {level: level_to_object(_hls.levels[e.loadMetrics.level])});
	}

	private static function on_seek_state(e: HLSEvent): void
	{
            JSAPI.postMessage('flashls.'+e.type, {state: e.state, seek_pos: _hls.position, buffer: _hls.stream.bufferLength});
	}

        private static function on_event(e:HLSEvent):void{
	    if (_silence)
	        return;
            JSAPI.postMessage('flashls.'+e.type, {url: e.url, level: e.level,
		duration: e.duration, levels: e.levels, error: e.error,
		loadMetrics: e.loadMetrics, playMetrics: e.playMetrics,
		mediatime: e.mediatime, state: e.state,
		audioTrack: e.audioTrack, streamType: e.streamType});
        }

        private static function hola_version():Object{
            return {
                flashls_version: '0.4.4.20',
                patch_version: '2.0.13'
            };
        }

        private static function hola_hls_get_video_url():String{
            return _url;
        }

        private static function hola_hls_get_position():Number{
            return _hls.position;
        }

        private static function hola_hls_get_duration():Number{
            return _duration;
        }

        private static function hola_hls_get_decoded_frames(): Number
	{
            return _hls.stream.decodedFrames;
        }

        private static function hola_hls_get_buffer_sec():Number{
            return _hls.stream.bufferLength;
        }

        private static function hola_hls_get_state():String{
            return _state;
        }

        private static function hola_hls_get_type():String{
            return _hls.type;
        }

        private static function hola_hls_load_fragment(level: Number, frag: Number, url: String): Object
	{
	    if (HSettings.gets('mode')!='hola_adaptive')
	        return 0;
	    return _hls.loadFragment(level, frag, url);
        }

	private static function hola_hls_flush_stream(): void
	{
	    if (_hls.stream.decodedFrames === 0)
	        return;
	    _silence = true;
	    _hls.stream.close();
	    _hls.stream.play();
            _hls.stream.pause();
	    _silence = false;
	}

        private static function hola_hls_abort_fragment(ldr_id: String): void
	{
	    if (HSettings.gets('mode')!='hola_adaptive')
	        return;
	    _hls.abortFragment(ldr_id);
        }

	private static function hola_hls_load_level(level: Number): void
	{
	    if (HSettings.gets('mode')!='hola_adaptive')
	        return;
	    if (!_hls.isStartLevelSet())
	        _hls.startLevel = level;
	    _hls.dispatchEvent(new HLSEvent(HLSEvent.LEVEL_SWITCH, level));
        }

        private static function level_to_object(l: Level): Object
	{
            var fragments: Array = [];
	    for (var i: int = 0; i<l.fragments.length; i++)
	    {
	        var fragment: Fragment = l.fragments[i];
	        fragments.push({url: fragment.url,
		    duration: fragment.duration, seqnum: fragment.seqnum});
	    }	
	    return {url: l.url, bitrate: l.bitrate, fragments: fragments,
	        index: l.index, width: l.width, height: l.height, audio: l.audio};
	}

        private static function hola_hls_get_levels():Object{
            var levels:Vector.<Object> = 
                new Vector.<Object>(_hls.levels.length);
            for (var i:int = 0; i<_hls.levels.length; i++)
            {
                var l:Level = _hls.levels[i];
                // no fragments returned, use get_segment_info for fragm.info
                levels[i] = Object({url: l.url, bitrate: l.bitrate,
                    index: l.index, fragments: []});

                hola_hls_get_buffer_sec);
            ExternalInterface.addCallback("hola_hls_get_state",
                hola_hls_get_state);
            ExternalInterface.addCallback("hola_hls_get_current_fragment",
                hola_hls_get_current_fragment);
            ExternalInterface.addCallback("hola_hls_get_levels",
                hola_hls_get_levels);
            ExternalInterface.addCallback("hola_hls_get_levels_async",
                hola_hls_get_levels_async);
            ExternalInterface.addCallback("hola_hls_get_segment_info",
                hola_hls_get_segment_info);
            ExternalInterface.addCallback("hola_hls_get_level",
                hola_hls_get_level);
            ExternalInterface.addCallback("hola_hls_get_bitrate",
                hola_hls_get_bitrate);
            ExternalInterface.addCallback("hola_hls_get_decoded_frames",
                hola_hls_get_decoded_frames);
            ExternalInterface.addCallback("hola_setBandwidth",
                hola_setBandwidth);
            ExternalInterface.addCallback("hola_hls_setBandwidth",
