my idea is to write a plugin that serves the MediaMonkey Library. My plan is to use a modified MediaLibrary class. I would like to add a new folder to the root of the UPNP root, but I do not want to make MediaMonkey part of the main code, just a plugin. The actual plugin system shows these two ExternalListeners:
- StartStopListener, for doing things like updating playcounts
- AdditionalResourceFolderListener, that adds a folder like the #Transcode# one.
- Code: Select all
Index: net/pms/external/AdditionalFolderAtRoot.java
===================================================================
--- net/pms/external/AdditionalFolderAtRoot.java (revision 0)
+++ net/pms/external/AdditionalFolderAtRoot.java (revision 0)
@@ -0,0 +1,20 @@
+/**
+ *
+ */
+package net.pms.external;
+
+import net.pms.dlna.DLNAResource;
+
+/**Extends the plugin system in that it adds an extra VirtualFolder. Plugin will
+ * be instantiated like any other ExternalListener.
+ *
+ * PMS.manageroot() will call the getChild() function that returns the VirtualFolder
+ * that gets added to the root of the UPNP server.
+ *
+ * @author el.botijo
+ *
+ */
+public interface AdditionalFolderAtRoot extends ExternalListener {
+
+ public DLNAResource getChild();
+}
Index: net/pms/PMS.java
===================================================================
--- net/pms/PMS.java (revision 386)
+++ net/pms/PMS.java (working copy)
@@ -75,6 +75,7 @@
import net.pms.encoders.TsMuxerAudio;
import net.pms.encoders.VideoLanAudioStreaming;
import net.pms.encoders.VideoLanVideoStreaming;
+import net.pms.external.AdditionalFolderAtRoot;
import net.pms.external.ExternalFactory;
import net.pms.external.ExternalListener;
import net.pms.formats.DVRMS;
@@ -546,6 +547,8 @@
}
addMediaLibraryFolder(renderer);
+
+ addAdditionalFoldersAtRoot(renderer);
addVideoSettingssFolder(renderer);
@@ -553,6 +556,16 @@
}
+ /**Adds a new DLNAResource at the root of the UPNP server
+ * @param renderer
+ */
+ private void addAdditionalFoldersAtRoot(RendererConfiguration renderer) {
+ for(ExternalListener listener:ExternalFactory.getExternalListeners()) {
+ if (listener instanceof AdditionalFolderAtRoot)
+ getRootFolder(renderer).addChild(((AdditionalFolderAtRoot) listener).getChild());
+ }
+ }
+
@SuppressWarnings("unchecked")
public void addiPhotoFolder(RendererConfiguration renderer) {
if (Platform.isMac()) {
Compiled sucessfully, and working, as far as I have seen. Please review the code. Comments are welcome, of course. Names can change to accommodate developers naming scheme.
A plugin that uses this kind of mechanism looks like this (I left just the skel):
- Code: Select all
package net.pms.external;
import net.pms.PMS;
import net.pms.dlna.DLNAResource;
import net.pms.dlna.RealFile;
import net.pms.dlna.virtual.VirtualFolder;
public class MM_plugin implements AdditionalFolderAtRoot{
private VirtualFolder MMroot;
public MM_plugin() {
this.MMroot = new VirtualFolder("MediaMonkey rules",null);
this.MMroot.addChild( new RealFile(new File("test.mp3"))); //Dummy thing, just in case
}
public DLNAResource getChild(){
return MMroot;
}
@Override
public JComponent config() {
// Removed code for creating buttons
return null;
}
/* (non-Javadoc)
* @see net.pms.external.ExternalListener#name()
*/
@Override
public String name() {
return "Configure MediaMonkey Plugin...";
}
@Override
public void shutdown() {
// nothing to do yet
}
}
Regards.
