new plugin: ViewStatus (see if file played before)

Discuss issues related to PS3 Media Server development (only for programmers)

new plugin: ViewStatus (see if file played before)

Postby SeeSoubleYou » Mon Nov 21, 2011 9:31 pm

Hey Guys,

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/
Attachments
DLNAMediaInfo.java.zip
(10.92 KiB) Downloaded 165 times
It is actually SeeDoubleYou...
SeeSoubleYou
 
Posts: 21
Joined: Sun Jan 10, 2010 8:57 pm

Re: new plugin: ViewStatus (see if file played before)

Postby SeeSoubleYou » Wed Dec 07, 2011 10:24 am

Would any of the main developers care to react on this plugin? I'd really like to see you comments.

I found two things that cause some problems.
One is that the stop event doesn't get called when you view several files after each other, that is when the playstation automatically skips to the next file when the previous is done. I could solve this with a queue, but this means the plugin will fail when using more then one renderer at the same time.
The second is described above as well, that there's no way (that I have found) to see at which point in the file was stopped.

Really hope to hear from someone here.
It is actually SeeDoubleYou...
SeeSoubleYou
 
Posts: 21
Joined: Sun Jan 10, 2010 8:57 pm

Re: new plugin: ViewStatus (see if file played before)

Postby SubJunk » Wed Dec 07, 2011 10:57 pm

Cool idea, I had often thought that would be a cool feature :)
SubJunk
 
Posts: 1212
Joined: Fri Mar 27, 2009 5:25 am

Re: new plugin: ViewStatus (see if file played before)

Postby SeeSoubleYou » Tue Jan 03, 2012 4:38 pm

Going to try this one more time. Does any of the core developers care to give their opinion on the above questions. I really think it would encourage developers if they would get a least some form of a reaction over time. Please take some time to read my post an react on it. It will help me and other developers to create better plugins based on aforementioned features.
It is actually SeeDoubleYou...
SeeSoubleYou
 
Posts: 21
Joined: Sun Jan 10, 2010 8:57 pm

Re: new plugin: ViewStatus (see if file played before)

Postby taconaut » Tue Jan 03, 2012 6:57 pm

Having dynamically generated thumbnails (with overlays) would be a nice thing. I've planned to add such a plugin system to pms-mlx where all information like cover, resolution, audio/video format... will be available to create the thumbnail (the play completion you want to show doesn't exist but could easily be added). So, I think it's a good idea but not at the right place :/
If you always wanted to have your most recent videos at the top of the folder in the ps3 or wished you could group all videos with the same genre in one folder, have a look at pms-mlx
taconaut
Project Member
 
Posts: 1104
Joined: Sat Apr 11, 2009 12:29 am
Location: Switzerland

Re: new plugin: ViewStatus (see if file played before)

Postby StreamHD » Wed Jan 04, 2012 4:56 pm

I also like the idea of dynamic thumbnail generation. Some non-PS3 renderers expect a specific aspect ratio for thumbnails, and if it isn't right then the thumbnail becomes horribly distorted.
PMS 1.50.1-Snapshot (latest commit); 400MB buffer;
Samsung LCD D550 Series with custom conf; Sony PS3; Xbox 360;
Win7 x64; JDK-7u2-x64; Intel i7 930 + X58 chipset; 3 x 2GB DDR3 1333Mhz; Gigabit backbone;
StreamHD
 
Posts: 63
Joined: Tue Dec 20, 2011 3:26 am

Re: new plugin: ViewStatus (see if file played before)

Postby Vallaquenta » Wed Jan 04, 2012 5:12 pm

StreamHD wrote:I also like the idea of dynamic thumbnail generation. Some non-PS3 renderers expect a specific aspect ratio for thumbnails, and if it isn't right then the thumbnail becomes horribly distorted.


True, but maybe build it for the PS3 first (since it's called PS3 Media Server). Once you're done developing it for the PS3, you can look into compatibility related things.
User avatar
Vallaquenta
 
Posts: 30
Joined: Wed Jan 04, 2012 11:00 am

Re: new plugin: ViewStatus (see if file played before)

Postby SeeSoubleYou » Wed Jan 04, 2012 6:31 pm

The biggest problem for other users is that my plugin can't be used at the moment unless you compile the whole server yourself. I have some other ideas based on the same feature but Why should I bother to make it a plugin when people have to compile themselves anyway, right?

taconaut wrote:Having dynamically generated thumbnails (with overlays) would be a nice thing. I've planned to add such a plugin system to pms-mlx where all information like cover, resolution, audio/video format... will be available to create the thumbnail (the play completion you want to show doesn't exist but could easily be added). So, I think it's a good idea but not at the right place :/


why is it not at the right place? Could you please elaborate more?
It is actually SeeDoubleYou...
SeeSoubleYou
 
Posts: 21
Joined: Sun Jan 10, 2010 8:57 pm

Re: new plugin: ViewStatus (see if file played before)

Postby squadjot » Thu Jan 05, 2012 12:46 pm

Good idea, allthough, if i had the skill to make a plugin, i'd would have made it based on a "user" rating..
And the logic would then be , if the movie has not been rated.. it has not been viewed.
User avatar
squadjot
 
Posts: 243
Joined: Thu Mar 25, 2010 10:03 pm

Re: new plugin: ViewStatus (see if file played before)

Postby taconaut » Thu Jan 05, 2012 5:57 pm

SeeSoubleYou wrote:why is it not at the right place? Could you please elaborate more?

For two reasons; if a plugin system is being created now, it will be applicable to all folders, whereas it is possible to set different icons for every folder in pms-mlx (you might want to show it differently if it is for tv series, family videos or movies). Additionally, more data is available to e.g. automatically generate a thumbnail like the cover generator site does it.
I'd like avoiding to add a plugin system for thumbnails to the current code, as it will become obsolete in the not too distant future (we're talking months and not years anymore).
If you always wanted to have your most recent videos at the top of the folder in the ps3 or wished you could group all videos with the same genre in one folder, have a look at pms-mlx
taconaut
Project Member
 
Posts: 1104
Joined: Sat Apr 11, 2009 12:29 am
Location: Switzerland

Next

Return to Developers

Who is online

Users browsing this forum: No registered users and 2 guests