@Override public void updateThumb(DLNAMediaInfo media, InputFile f) { try { BufferedImage image = ImageIO.read(new ByteArrayInputStream(media.getThumb())); if (image != null) { Graphics g = image.getGraphics(); Path infoFilePath = Paths.get(f.getFile().getPath()); // get path of current file String folderName = infoFilePath.getParent().toString(); // get folder String infoFile = folderName + "/.viewstatus"; // get get infofilename String infoKey = f.getFile().getName(); // get keyname Properties props = new Properties(); try { props.load(new FileInputStream(infoFile)); String viewInfo = ""; String allViewed = props.getProperty("allviewed", "false"); // if allview=true is in the infofile, mark media as viewed if (allViewed.equals("true")) { viewInfo = "viewed"; } else { // get viewing percentage from infofile int fileViewPercentage = Integer.parseInt(props.getProperty(infoKey, "0")); if (fileViewPercentage != 0) { viewInfo = "viewed for " + fileViewPercentage + "%"; } } // if info was set, draw it on the thumbnail if (viewInfo != "") { // draw a senitransparent black bar to increase readability g.setColor(new Color(0, 0, 0, 190)); g.fillRect(0, image.getHeight() - 35, image.getWidth(), 35); // draw info g.setFont(new Font("Arial", Font.PLAIN, 25)); g.setColor(new Color(240, 240, 240)); FontMetrics fm = g.getFontMetrics(); int viewInfoX = (image.getWidth() - fm.stringWidth(viewInfo)) / 2; int viewInfoY = image.getHeight() - 7; g.drawString(viewInfo, viewInfoX, viewInfoY); ByteArrayOutputStream out = new ByteArrayOutputStream(); ImageIO.write(image, "jpeg", out); media.setThumb(out.toByteArray()); } } catch (IOException e) { } } } catch (IOException e) { log.error("Error while updating thumbnail : " + e.getMessage()); } }