@Override public byte[] generate(byte[] original, MediaItem mediaItem) throws ThumbnailGeneratorException { try { byte[] thumb = ImageUtils.generateThumbnail(original, WIDTH, HEIGHT, 100); return thumb; } catch (InterruptedException ex) { logger.log(Level.WARNING, "Could not generate thumbnail", ex); } catch (IOException ex) { logger.log(Level.WARNING, "Could not generate thumbnail", ex); } // Fallback InputStream is = null; byte[] output = null; try { is = getClass().getResourceAsStream("/dk/i2m/converge/core/content/unknown-media-item.png"); try { output = FileUtils.getBytes(is); } catch (Exception e) { logger.log(Level.SEVERE, "Could not generate audio thumbnail", e); } finally { is.close(); } return output; } catch (IOException ex) { logger.log(Level.SEVERE, "Could not generate audio thumbnail", ex); throw new ThumbnailGeneratorException("Could not generate fallback thumbnail", ex); } }
@Override public byte[] generate(byte[] original, MediaItem mediaItem) throws ThumbnailGeneratorException { InputStream is = null; byte[] output = null; try { is = getClass().getResourceAsStream("/dk/i2m/converge/core/content/audio-media-item.png"); try { output = FileUtils.getBytes(is); } catch (Exception e) { logger.log(Level.SEVERE, "Could not generate audio thumbnail", e); } finally { is.close(); } return output; } catch (IOException ex) { logger.log(Level.SEVERE, "Could not generate audio thumbnail", ex); throw new ThumbnailGeneratorException("Could not generate fallback thumbnail", ex); } }