         /* demux instance */
         private var _demux : Demuxer;
         /* key error/reload */
-        private var _key_load_error : Boolean;
         private var _key_load_error_date : Number = 0;
         private var _key_retry_timeout : Number;
         private var _key_retry_count : int;
         private var _key_load_status : int;
         /* fragment error/reload */
-        private var _frag_load_error : Boolean;
         private var _frag_load_error_date : Number = 0;
         private var _frag_retry_timeout : Number;
         private var _frag_retry_count : int;
         private var _frag_load_status : int;
-        /** Store that a fragment load is in progress. **/
-        private var _frag_loading : Boolean;
         /** reference to previous/current fragment */
         private var _frag_previous : Fragment;
         private var _frag_current : Fragment;
         /* loading state variable */
-        private static const LOADING_IN_PROGRESS : int = 0;
-        private static const LOADING_WAITING : int = 1;
-        private static const LOADING_OUTDATED : int = -1;
+        private var _loading_state : int;
+        private static const LOADING_IDLE : int = 0;
+        private static const LOADING_IN_PROGRESS : int = 1;
+        private static const LOADING_WAITING_LEVEL_UPDATE : int = 2;
+        private static const LOADING_STALLED : int = 3;
+        private static const LOADING_FRAGMENT_IO_ERROR : int = 4;
+        private static const LOADING_KEY_IO_ERROR : int = 5;
 
         /** Create the loader. **/
         public function FragmentLoader(hls : HLS, audioTrackController : AudioTrackController) : void {

        }

        private function _fragDecryptCompleteHandler() : void {
            if (_cancel_load == true)
                return;
            var fragData : FragmentData = _frag_current.data;


        private var _switchlevel : Boolean;
        /** Did a discontinuity occurs in the stream **/
        private var _hasDiscontinuity : Boolean;
        /** boolean to track whether PTS analysis is ongoing or not */
        private var _pts_analyzing : Boolean = false;
        /** boolean to indicate that PTS has just been analyzed */
