I started on a plugin that can mark files as viewed. I had to create a new plugin type though. I have added it as an attachment (ThumbnailExtras.java zipped). As this filename suggests the thumbnail of videofiles can be altered with this new plugintype. My plugin uses this to show an overlay showing whether a (video)file was played. It uses a hidden file (.viewstatus) in the folder of the file to store how much percent of a file was viewed. The reason that it uses a file is that it is easy to handle for everyone. You can also create this file yourself and when you add a line "allviewed=true" to the file, all files in the folder will be marked as viewed. At this point I have Altered DLNAMediaInfo.java to incorporate this new functionality. Below is the patch. For more detail, please see https://code.google.com/p/ps3mediaserver-plugin-viewstatus/.
- Code: Select all
Index: net/pms/dlna/DLNAMediaInfo.java
===================================================================
--- net/pms/dlna/DLNAMediaInfo.java (revision 997)
+++ net/pms/dlna/DLNAMediaInfo.java (working copy)
@@ -50,6 +50,9 @@
import net.pms.util.FileUtil;
import net.pms.util.MpegUtil;
import net.pms.util.ProcessUtil;
+import net.pms.external.ExternalFactory;
+import net.pms.external.ExternalListener;
+import net.pms.external.ThumbnailExtras;
import org.apache.commons.lang.StringUtils;
import org.apache.sanselan.ImageInfo;
@@ -914,6 +917,7 @@
ByteArrayOutputStream out = new ByteArrayOutputStream();
ImageIO.write(image, "jpeg", out);
setThumb(out.toByteArray());
+ thumbnailExtras(f); // If a thumbnailExtras plugin was declared, call it to update thumb
}
}
} catch (IOException e) {
@@ -925,7 +929,23 @@
setMediaparsed(true);
}
}
-
+
+ /**
+ * This function calls every thumbnailExtras plugin (if any). Which will than be able
+ * to add stuff to the thumbnail.
+ *
+ * @param InputFile input. An InputFile is used since recource is not always available.
+ */
+ public void thumbnailExtras(InputFile input)
+ {
+ for(ExternalListener listener:ExternalFactory.getExternalListeners()) {
+ if (listener instanceof ThumbnailExtras)
+ {
+ ((ThumbnailExtras) listener).updateThumb(this, input);
+ }
+ }
+ }
+
public boolean isH264() {
return getCodecV() != null && getCodecV().contains("264");
}
There is some work that needs to be done to make things complete. For now, the plugins does not work when 'Use MPlayer for video thumbnails' is enabled. This could easily be done, but I didn't want to make the patch to long. If the new ThumbnailExtras type makes it into the release I'd be more than willing to put some extra work into it to make the flow of it all a bit nicer.
Also, I want the plugin to offer the option to have a thumbnail overlay and/or an extra message in the filename on the renderer. This could mean that ThumbnailExtras becomes a more general type like ExtraMediaInfo, or that a second plugin type is added, which is purely for the latter option.
The plugin has been tested on a PS3 and on an android device. The plugin works for the PS3 for the most part, I'll come back on that later. On the android device it depends on the render. It work with UPNPlay, but not with BubbleUPNP (which I normally prefer). This is because with the latter the method getDurationInSeconds() in DLNAMediaInfo is always 0 (see viewtopic.php?f=11&t=12623 also). This could be fixed by not asked the renderer for the duration I think, but that's more a general issue.
Now, about how the plugin work. I haven't been able to detect the number of seconds in the file at which a file was stopped. So for now, when a file start playing the time is recorded. Then when the file is stopped again the time is recorded. The difference is taken as a reference to determine how much of the file has been watched. The problem here is that when a file is paused, the time will not, so even if you watch only 20%, it can look like more because of the pause. Ideally, you'd want to know at which point the file was stopped to base the percentage on.
Please let me know what you think. I'd be happy to take any suggestions. You can find the project, as well as some more information on https://code.google.com/p/ps3mediaserver-plugin-viewstatus/
