             // dont spend more than 20ms demuxing TS packets to avoid loosing frames
             while(data  != null && ((getTimer() - start_time) < 20)) {
                 _parseTSPacket(data);
-                _read_position+=188;
-                if(data.bytesAvailable < 188) {
+                _read_position+=PACKETSIZE;
+                if(data.bytesAvailable < PACKETSIZE) {
                     data = getNextTSBuffer(_read_position);
                 }
             }

                _callback_progress(_tags);
                _tags = new Vector.<FLVTag>();
            }
            // finish reading TS fragment
            if (_data_complete && getNextTSBuffer(_read_position) == null) {
                // free ByteArray
                _dataVector = null;
                // first check if TS parsing was successful

        }

        private function getNextTSBuffer(start : int) : ByteArray {
            if(start + 188 <= _totalBytes) {
                // find element matching with start offset
                for(var i : int = 0, offset : int = _dataOffset; i < _dataVector.length; i++) {
                    var buffer : ByteArray = _dataVector[i], bufferLength : int = buffer.length;
                    if(start >= offset && start < offset + bufferLength) {
                        buffer.position = start - offset;
                        if(buffer.bytesAvailable >= PACKETSIZE) {
                            if(_pmtParsed && i) {
                                _dataVector.splice(0,i);
                                _dataOffset = offset;
                            }
                            return buffer;
                        } else {
                            // TS packet overlapping between several buffers
                            var ba : ByteArray = new ByteArray();
                            ba.writeBytes(buffer, buffer.position);
                            while(++i < _dataVector.length && ba.length < PACKETSIZE) {
                                buffer = _dataVector[i];
                                buffer.position = 0;
                                ba.writeBytes(buffer,0,Math.min(PACKETSIZE-ba.position,buffer.length));
                            }
                            if(ba.length == PACKETSIZE) {
                                ba.position = 0;
                                return ba;
                            }
                            // we should never reach this point
                            // if TS overlapping but next buffer not available or next buffer not full enough, return null
                            //Log.error("TS overlapping but next buffer not full enough:" + _read_position + "/" + _totalBytes + "/" + ba.length);
                            return null;
                        }
                    }
                    offset += bufferLength;
                }
            }
            return null;
        }
