private void treadBufferingLogic() {
		Thread bufferingThread = new Thread(new Runnable() {
			
			@Override
			public void run() {
				final int BUFFER_IMAGE_STEP = 5;
				
				for(int i = 0; !endOfFrames; i+=5){
					
					try {
						addFramesToQuese(i, i + BUFFER_IMAGE_STEP);
					} catch (JCodecException e) {
						endOfFrames = true;
					} catch (IOException e) {
						e.printStackTrace();
					}
					
					//Sleeps the thread until some images are printed ( 24 frames a second )
					if(bufferedFrames.size() > MAX_BUFFER_SIZE){
						try {
							Thread.sleep(playSpeed*50);
						} catch (InterruptedException e) { }
					}
					if(bufferedFrames.size() > 50 && mainThread.getState() == State.TIMED_WAITING){
						mainThread.interrupt();
					}
				}
			}

		});
		
		bufferingThread.start();
	}