This question is answered. Helpful answers available: 1. Correct answers available: 1.


Permlink Replies: 12 - Pages: 1 - Last Post: 20-Sep-2017 13:07 Last Post By: jGromit
ctwist

Posts: 1,389
Registered: 09/27/03
Superimposed "play" button
Posted: 16-Sep-2017 05:08
 
  Click to reply to this thread Reply
jAlbum superimposes a "play" button on video thumbnails. I want to achieve the same effect on Mirage variant video thumbnails.

Is there a suitable snippet that I can steal from jAlbum to accomplish this?
davidekholm

Posts: 21,290
Registered: 10/18/02
Re: Superimposed "play" button
Posted: 18-Sep-2017 18:21   in response to: ctwist in response to: ctwist
Helpful
  Click to reply to this thread Reply
Attachment ForCategory.class (1.3 KB)
Attachment ForCategory.java (930 bytes)
Here's a way. Put the attached files in the "plugins" folder of your skin.
In init.bsh, add the following (pasting the Dor logo currently):
engine.setSuperimposeFilmIcon(false); // Switch off default play button superimposing
LogoFilter logo = new LogoFilter();
logo.setSrc("http://blog.jalbum.net/dor.png");
logo.setAlign("center");
logo.setValign("center");
logo.setStrengthPercent(50);
 
engine.addFilter(new ForCategory(Category.video, logo), JAFilter.THUMBNAILS_POSTSCALE_STAGE);
engine.addFilter(new ForCategory(Category.video, logo), JAFilter.CLOSEUPS_POSTSCALE_STAGE);


You may need to do a "Make all" to trigger the generation.

Edited by: davidekholm on 19-Sep-2017 20:20
Added default constructor to ForCategory
RobM

Posts: 4,250
Registered: 08/04/06
Re: Superimposed "play" button
Posted: 18-Sep-2017 20:49   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
davidekholm wrote:
Here's a way. Put the attached files in the "plugins" folder of your skin.
In init.bsh, add the following (pasting the Dor logo currently):
engine.setSuperimposeFilmIcon(false); // Switch off default play button superimposing
LogoFilter logo = new LogoFilter();
logo.setSrc("http://blog.jalbum.net/dor.png");
logo.setAlign("center");
logo.setValign("center");
logo.setStrengthPercent(50);
 
engine.addFilter(new ForCategory(Category.video, logo), JAFilter.THUMBNAILS_POSTSCALE_STAGE);
engine.addFilter(new ForCategory(Category.video, logo), JAFilter.CLOSEUPS_POSTSCALE_STAGE);

You may need to do a "Make all" to trigger the generation.

I have tried the above in a few skins and it destroys images in the project :(

After making the album I get
java.lang.InstantiationException: ForCategory
	at java.lang.Class.newInstance(Class.java:427)
	at sun.reflect.GeneratedMethodAccessor26.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:71)
	at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:275)
	at java.beans.Statement.invokeInternal(Statement.java:292)
	at java.beans.Statement.access$000(Statement.java:58)
	at java.beans.Statement$2.run(Statement.java:185)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.beans.Statement.invoke(Statement.java:182)
	at java.beans.Expression.getValue(Expression.java:155)
	at java.beans.Encoder.getValue(Encoder.java:105)
	at java.beans.Encoder.get(Encoder.java:252)
	at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:112)
	at java.beans.Encoder.writeObject(Encoder.java:74)
	at java.beans.XMLEncoder.writeObject(XMLEncoder.java:327)
	at java.beans.Encoder.writeExpression(Encoder.java:330)
	at java.beans.XMLEncoder.writeExpression(XMLEncoder.java:454)
	at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:115)
	at java.beans.Encoder.writeObject(Encoder.java:74)
	at java.beans.XMLEncoder.writeObject(XMLEncoder.java:327)
	at java.beans.Encoder.writeExpression(Encoder.java:330)
	at java.beans.XMLEncoder.writeExpression(XMLEncoder.java:454)
	at java.beans.DefaultPersistenceDelegate.doProperty(DefaultPersistenceDelegate.java:196)
	at java.beans.DefaultPersistenceDelegate.initBean(DefaultPersistenceDelegate.java:258)
	at java.beans.DefaultPersistenceDelegate.initialize(DefaultPersistenceDelegate.java:406)
	at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:118)
	at java.beans.Encoder.writeObject(Encoder.java:74)
	at java.beans.XMLEncoder.writeObject(XMLEncoder.java:327)
	at java.beans.Encoder.writeExpression(Encoder.java:330)
	at java.beans.XMLEncoder.writeExpression(XMLEncoder.java:454)
	at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:115)
	at java.beans.Encoder.writeObject(Encoder.java:74)
	at java.beans.XMLEncoder.writeObject(XMLEncoder.java:327)
	at java.beans.Encoder.writeObject1(Encoder.java:258)
	at java.beans.Encoder.cloneStatement(Encoder.java:271)
	at java.beans.Encoder.writeStatement(Encoder.java:301)
	at java.beans.XMLEncoder.writeStatement(XMLEncoder.java:400)
	at java.beans.DefaultPersistenceDelegate.invokeStatement(DefaultPersistenceDelegate.java:219)
	at java.beans.MetaData$java_util_List_PersistenceDelegate.initialize(MetaData.java:655)
	at java.beans.PersistenceDelegate.initialize(PersistenceDelegate.java:214)
	at java.beans.DefaultPersistenceDelegate.initialize(DefaultPersistenceDelegate.java:404)
	at java.beans.PersistenceDelegate.initialize(PersistenceDelegate.java:214)
	at java.beans.DefaultPersistenceDelegate.initialize(DefaultPersistenceDelegate.java:404)
	at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:118)
	at java.beans.Encoder.writeObject(Encoder.java:74)
	at java.beans.XMLEncoder.writeObject(XMLEncoder.java:327)
	at java.beans.Encoder.writeExpression(Encoder.java:330)
	at java.beans.XMLEncoder.writeExpression(XMLEncoder.java:454)
	at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:115)
	at java.beans.Encoder.writeObject(Encoder.java:74)
	at java.beans.XMLEncoder.writeObject(XMLEncoder.java:327)
	at java.beans.Encoder.writeExpression(Encoder.java:330)
	at java.beans.XMLEncoder.writeExpression(XMLEncoder.java:454)
	at java.beans.MetaData$java_util_Map_PersistenceDelegate.initialize(MetaData.java:685)
	at java.beans.PersistenceDelegate.initialize(PersistenceDelegate.java:214)
	at java.beans.DefaultPersistenceDelegate.initialize(DefaultPersistenceDelegate.java:404)
	at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:118)
	at java.beans.Encoder.writeObject(Encoder.java:74)
	at java.beans.XMLEncoder.writeObject(XMLEncoder.java:327)
	at java.beans.Encoder.writeExpression(Encoder.java:330)
	at java.beans.XMLEncoder.writeExpression(XMLEncoder.java:454)
	at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:115)
	at java.beans.Encoder.writeObject(Encoder.java:74)
	at java.beans.XMLEncoder.writeObject(XMLEncoder.java:327)
	at java.beans.Encoder.writeObject1(Encoder.java:258)
	at java.beans.Encoder.cloneStatement(Encoder.java:271)
	at java.beans.Encoder.writeStatement(Encoder.java:301)
	at java.beans.XMLEncoder.writeStatement(XMLEncoder.java:400)
	at java.beans.XMLEncoder.writeObject(XMLEncoder.java:330)
	at se.datadosen.jalbum.AlbumBean.getImageSettingsHash(AlbumBean.java:789)
	at se.datadosen.jalbum.AlbumBean.makeAlbum(AlbumBean.java:2609)
	at se.datadosen.jalbum.AlbumBean.smartMakeAlbum(AlbumBean.java:2571)
	at se.datadosen.jalbum.JAlbumFrame$10.run(JAlbumFrame.java:1064)
Caused by: java.lang.NoSuchMethodException: ForCategory.<init>()
	at java.lang.Class.getConstructor0(Class.java:3082)
	at java.lang.Class.newInstance(Class.java:412)
	... 77 more
java.lang.RuntimeException: failed to evaluate: <unbound>=Class.new();
	at java.beans.Encoder.getValue(Encoder.java:109)
	at java.beans.Encoder.get(Encoder.java:252)
	at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:112)
	at java.beans.Encoder.writeObject(Encoder.java:74)
	at java.beans.XMLEncoder.writeObject(XMLEncoder.java:327)
	at java.beans.Encoder.writeExpression(Encoder.java:330)
	at java.beans.XMLEncoder.writeExpression(XMLEncoder.java:454)
	at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:115)
	at java.beans.Encoder.writeObject(Encoder.java:74)
	at java.beans.XMLEncoder.writeObject(XMLEncoder.java:327)
	at java.beans.Encoder.writeExpression(Encoder.java:330)
	at java.beans.XMLEncoder.writeExpression(XMLEncoder.java:454)
	at java.beans.DefaultPersistenceDelegate.doProperty(DefaultPersistenceDelegate.java:196)
	at java.beans.DefaultPersistenceDelegate.initBean(DefaultPersistenceDelegate.java:258)
	at java.beans.DefaultPersistenceDelegate.initialize(DefaultPersistenceDelegate.java:406)
	at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:118)
	at java.beans.Encoder.writeObject(Encoder.java:74)
	at java.beans.XMLEncoder.writeObject(XMLEncoder.java:327)
	at java.beans.Encoder.writeExpression(Encoder.java:330)
	at java.beans.XMLEncoder.writeExpression(XMLEncoder.java:454)
	at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:115)
	at java.beans.Encoder.writeObject(Encoder.java:74)
	at java.beans.XMLEncoder.writeObject(XMLEncoder.java:327)
	at java.beans.Encoder.writeObject1(Encoder.java:258)
	at java.beans.Encoder.cloneStatement(Encoder.java:271)
	at java.beans.Encoder.writeStatement(Encoder.java:301)
	at java.beans.XMLEncoder.writeStatement(XMLEncoder.java:400)
	at java.beans.DefaultPersistenceDelegate.invokeStatement(DefaultPersistenceDelegate.java:219)
	at java.beans.MetaData$java_util_List_PersistenceDelegate.initialize(MetaData.java:655)
	at java.beans.PersistenceDelegate.initialize(PersistenceDelegate.java:214)
	at java.beans.DefaultPersistenceDelegate.initialize(DefaultPersistenceDelegate.java:404)
	at java.beans.PersistenceDelegate.initialize(PersistenceDelegate.java:214)
	at java.beans.DefaultPersistenceDelegate.initialize(DefaultPersistenceDelegate.java:404)
	at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:118)
	at java.beans.Encoder.writeObject(Encoder.java:74)
	at java.beans.XMLEncoder.writeObject(XMLEncoder.java:327)
	at java.beans.Encoder.writeExpression(Encoder.java:330)
	at java.beans.XMLEncoder.writeExpression(XMLEncoder.java:454)
	at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:115)
	at java.beans.Encoder.writeObject(Encoder.java:74)
	at java.beans.XMLEncoder.writeObject(XMLEncoder.java:327)
	at java.beans.Encoder.writeExpression(Encoder.java:330)
	at java.beans.XMLEncoder.writeExpression(XMLEncoder.java:454)
	at java.beans.MetaData$java_util_Map_PersistenceDelegate.initialize(MetaData.java:685)
	at java.beans.PersistenceDelegate.initialize(PersistenceDelegate.java:214)
	at java.beans.DefaultPersistenceDelegate.initialize(DefaultPersistenceDelegate.java:404)
	at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:118)
	at java.beans.Encoder.writeObject(Encoder.java:74)
	at java.beans.XMLEncoder.writeObject(XMLEncoder.java:327)
	at java.beans.Encoder.writeExpression(Encoder.java:330)
	at java.beans.XMLEncoder.writeExpression(XMLEncoder.java:454)
	at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:115)
	at java.beans.Encoder.writeObject(Encoder.java:74)
	at java.beans.XMLEncoder.writeObject(XMLEncoder.java:327)
	at java.beans.Encoder.writeObject1(Encoder.java:258)
	at java.beans.Encoder.cloneStatement(Encoder.java:271)
	at java.beans.Encoder.writeStatement(Encoder.java:301)
	at java.beans.XMLEncoder.writeStatement(XMLEncoder.java:400)
	at java.beans.XMLEncoder.writeObject(XMLEncoder.java:330)
	at se.datadosen.jalbum.AlbumBean.getImageSettingsHash(AlbumBean.java:789)
	at se.datadosen.jalbum.AlbumBean.makeAlbum(AlbumBean.java:2609)
	at se.datadosen.jalbum.AlbumBean.smartMakeAlbum(AlbumBean.java:2571)
	at se.datadosen.jalbum.JAlbumFrame$10.run(JAlbumFrame.java:1064)

After making the album and trying to remake it I get multiple:
The following files could not be processed due to errors:
Jelly fish.jpg: javax.imageio.IIOException: Not a JPEG file: starts with 0xff 0xd9
The images have zero bytes size
RobM

Posts: 4,250
Registered: 08/04/06
Re: Superimposed "play" button
Posted: 18-Sep-2017 21:15   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
The command engine.addFilter(new ForCategory(Category.video, logo), JAFilter.THUMBNAILS_POSTSCALE_STAGE);
produces the first error but the album thumbnails do get the For image as an overlay to videos.

The command engine.addFilter(new ForCategory(Category.video, logo), JAFilter.CLOSEUPS_POSTSCALE_STAGE);
Destroys the project images.

Tests performed with a copy of Minimal with just the plugin and init.bsh code modified.
jGromit

Posts: 32,917
Registered: 01/31/06
Re: Superimposed "play" button
Posted: 18-Sep-2017 21:32   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
This is one of the reasons why, in my own skins, I do the thumbnail overlays with some very simple CSS. That way, I can control position, size, opacity, etc. And there's no image regeneration involved.
RobM

Posts: 4,250
Registered: 08/04/06
Re: Superimposed "play" button
Posted: 18-Sep-2017 21:46   in response to: jGromit in response to: jGromit
 
  Click to reply to this thread Reply
jGromit wrote:
This is one of the reasons why, in my own skins, I do the thumbnail overlays with some very simple CSS. That way, I can control position, size, opacity, etc. And there's no image regeneration involved.
It's also the reason I use a copy of the Sample Portfolio for testing things like this - no real damage done.
ctwist

Posts: 1,389
Registered: 09/27/03
Re: Superimposed "play" button
Posted: 19-Sep-2017 05:43   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
Attachment play.png (20.0 KB)
Not exactly what I was looking for, but it pointed me in the right direction. I don't want to replace jAlbum's technique; I want to replicate it.

This works:
1) Include a play icon. I couldn't find jAlbum's icon, so I downloaded a free one (attached). I couldn't decide where to put it, so I put it in the skin's root directory.

2) Album initialisation. In class MgAlbum, I create a filter that resizes the icon based on the maximum variant thumbnail height (most of you probably have no idea what I am talking about).
	
		protected static LogoFilter vPlayIcon = new LogoFilter();
		// (convert \ to / )
		vPlayIcon.setSrc("file:///" + MgUtil.fGenericPath(skinDirectory.getPath()) + "/play.png");
		vPlayIcon.setAlign(Alignment.center);
		vPlayIcon.setValign(VerticalAlignment.center);
		vPlayIcon.setStrengthPercent(80);
		vPlayIcon.setScalePercent((int)(vMaxVariantThumbHeight * 0.4));
3) For each thumbnail that jAlbum is unaware of and that needs the "play" icon, after applying all other filters, add the play button.
    vAlbumImage = vAlbumImage.applyFilter(MgAlbum.vPlayIcon);
davidekholm

Posts: 21,290
Registered: 10/18/02
Re: Superimposed "play" button
Posted: 19-Sep-2017 20:22   in response to: ctwist in response to: ctwist
 
  Click to reply to this thread Reply
I hope your original images are untouched. I cannot reproduce this problem but I've adjusted the ForCategory class so at least the problem of attempting to run the default constructor shall be gone.
RobM

Posts: 4,250
Registered: 08/04/06
Re: Superimposed "play" button
Posted: 19-Sep-2017 20:51   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
davidekholm wrote:
I hope your original images are untouched. I cannot reproduce this problem but I've adjusted the ForCategory class so at least the problem of attempting to run the default constructor shall be gone.
That runs without any errors and leaves the original images intact.
davidekholm

Posts: 21,290
Registered: 10/18/02
Re: Superimposed "play" button
Posted: 19-Sep-2017 23:39   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
Great!
RobM

Posts: 4,250
Registered: 08/04/06
Re: Superimposed "play" button
Posted: 20-Sep-2017 00:23   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
davidekholm wrote:
Great!
Sort of ;)
It works well for categories videos and 'other' but not for folders - even if the image used as the thumbnail has been excluded, which you would need to do to stop it appearing on the normal image thumbnail.
davidekholm

Posts: 21,290
Registered: 10/18/02
Re: Superimposed "play" button
Posted: 20-Sep-2017 10:17   in response to: RobM in response to: RobM
 
  Click to reply to this thread Reply
RobM wrote:
davidekholm wrote:
Great!
Sort of ;)
It works well for categories videos and 'other' but not for folders - even if the image used as the thumbnail has been excluded, which you would need to do to stop it appearing on the normal image thumbnail.

Ah, folders are a special case as they don't produce images of their own but "lend" an image from their children. It's probably high time to change that as the extra bytesize and processing cost is small but the benefits are bigger (for instance the ability to have representing thumbnails for protected folders or custom overlay images on folders)
jGromit

Posts: 32,917
Registered: 01/31/06
Re: Superimposed "play" button
Posted: 20-Sep-2017 13:06   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
Isn't it high time we stopped forcing image processing just to produce an overlay on a thumbnail? Talk about a waste of processing resources!

Doing this with CSS requires no processing, and the icon can be placed anywhere, in any size, in any opacity. A user can even swap out the icon for his own simply by replacing what's in the skin directory.
Legend
Forum admins
Helpful Answer
Correct Answer

Point your RSS reader here for a feed of the latest messages in all forums