@Override
  public void donePlaying(DLNAMediaInfo media, DLNAResource resource) {
    // currently only for videofiles
    if (enabledMV && resource.getType() == Format.VIDEO) {
      // get path information
      Path infoFilePath = Paths.get(resource.getSystemName());
      String folderName = infoFilePath.getParent().toString();
      String infoFile = folderName + "/.viewstatus";
      String infoKey = resource.getName();

      // create handler for properties
      Properties props = new Properties();

      double fileViewPercentage = 0;

      try {
        props.load(new FileInputStream(infoFile)); // load the viewinfo file (if any)
        fileViewPercentage = Integer.parseInt(props.getProperty(infoKey, "0"));
      } catch (IOException e) {
        log.error("viewinfo at " + infoFile + " file does not yet exist");
      }

      double playLengthSec = 0; // total length of the file

      /**
       * @TODO: calculation below should work without startdate. Is it possible to get the exact
       * number of seconds the file was stopped?
       */
      playLengthSec = (int) (new Date().getTime() - startDates.poll().getTime()) / 1000;

      double fullLengthSec = media.getDurationInSeconds();

      if (fullLengthSec > 0) {
        double currentFileViewPercentage = (playLengthSec / fullLengthSec) * 100;

        // if the watched percentage is bigger than in the viewinfo file, write it to viewinfo
        if (currentFileViewPercentage > fileViewPercentage) {
          fileViewPercentage = Math.min(100, currentFileViewPercentage);
          props.setProperty(infoKey, Integer.toString((int) fileViewPercentage));

          try {
            props.store(new FileOutputStream(infoFile), null);

            // update the thumbnail
            media.setThumb(null);
            InputFile input = new InputFile();
            input.setFile(((RealFile) resource).getFile());
            media.generateThumbnail(input, resource.getExt(), resource.getType());

          } catch (IOException e) {
            logExeptionError(e);
          }
        }
      }
    }
  }
 @Override
 public void nowPlaying(DLNAMediaInfo media, DLNAResource resource) {
   if (enabledMV && resource.getType() == Format.VIDEO) {
     startDates.add(new Date()); // set the startdate
   }
 }