Browse Source

added fix for iZpl track pause, also doc rework

LH 9 năm trước cách đây
mục cha
commit
8e6cc5e4f7

+ 1 - 1
iZpl/src/main/java/de/nplusc/izc/iZpl/API/FeaturePlugin.java

@@ -17,7 +17,7 @@
 package de.nplusc.izc.iZpl.API;
 
 /**
- * FeaturePlugins are to interface to other programs which are not full mediaplayers like games.
+ * FeaturePlugins are to interface to other programs which are not full mediaplayers like games. Or to add other Features not provided by the core like editing iZpl-files
  * @author iZc <nplusc.de>
  */
 public interface FeaturePlugin extends Plugin

+ 44 - 7
iZpl/src/main/java/de/nplusc/izc/iZpl/API/IZPLApi.java

@@ -45,13 +45,25 @@ public class IZPLApi
      */
     public static final String APPDIR = new File(IZPLApi.class.getProtectionDomain().getCodeSource().getLocation().getPath()).getParentFile().getParent();
     
+    /**
+     * Defines the path to the base plugin directory
+     */
     public static final String PLUGINPATH = APPDIR + File.separator + "plugins";
+    /**
+     * defines the path to the base skin directory
+     */
     public static final String SKINPATH = APPDIR + File.separator + "skins";
     
+    /**
+     * defines the path to the folder used for temporary stuff, gets deleted on program exit
+     */
     public static final String TEMPDIR = System.getenv("temp")+File.separator+"izpl-workdata";
     
     private static final Logger l = LogManager.getLogger();
     
+    private IZPLApi()
+    {
+    }
     /**
      * Checks whether the Program runs in fully new UI mode or in the old Mode where only the managing UI is loaded
      * @return true when the program is in the new UI mode
@@ -110,13 +122,15 @@ public class IZPLApi
         return Main.getPLServer().ppp.getBlockRaw();
     }
     
+    /**
+     * Gets the playlist base folder as specified in the Playlist file
+     * @return Path to the root folder as string
+     */
     public static String getPlaylistRoot()
     {
         return Main.getPLServer().ppp.getPath();
     }
-    private IZPLApi()
-    {
-    }
+
     /**
      *  Obtains the List of the currently registered UI-Modules
      * @return the list of the registered UIs
@@ -177,7 +191,12 @@ public class IZPLApi
     {
         return System.console()!=null;
     }
-   
+    
+    /**
+     * Loads the playlist file into a List of @see(SinglePlayListItem)s, File doesnt get parsed for included files and other stuff to allow custom processing
+     * @param path path to the iZpl-file
+     * @return the Playlist elements
+     */
     public static List<SinglePlayListItem> readPlayList(String path) 
     {
         try
@@ -192,26 +211,44 @@ public class IZPLApi
         }
     }
     
-    
+    /**
+     * Loads a reference to the currently loaded FeaturePlugin
+     * @return FeaturePlugin main class
+     */
     public static FeaturePlugin getSelectedFeature()
     {
         return Main.getPluginManager().getSelectedFeaturePlugin();
     }
     
+    /**
+     * Call to save a playlist file
+     * @param f Playlist-File object to save as iZpl
+     */
     public static void saveFile(PlayListFile f)
     {
         PLFileIO.writePLFile(f);
     }
-    
+    /**
+     * returns the pluginManager that is currently active
+     * @return PluginManager
+     */
     public static PluginManager getPluginManager()
     {
         return Main.getPluginManager();
     }
-    
+    /**
+     * Returns wheter we are HTTP-streaming the audio instead of playing it
+     * @return true when the program is in HTTP streaming mode
+     */
     public static boolean isInHTTPStreamMode()
     {
         return Main.getStts().streaming;
     }
+    
+    /**
+     * Returns the currently used HTTP streaming port
+     * @return the Streamport if it is set and we are streaming, -1 otherwise
+     */
     public static int getHTTPStreamPort()
     {
         return Main.getStts().streamport;

+ 4 - 0
iZpl/src/main/java/de/nplusc/izc/iZpl/API/PlayListEditAPI.java

@@ -207,6 +207,10 @@ public class PlayListEditAPI
         Main.getPLServer().getPlProcessorV2().reloadLists(true);
     }
     
+    /**
+     * Sets the SortMode that should be used from now on @ the list
+     * @param mode SortMode to use
+     */
     public static void setSortMode(SortMode mode)
     {
         m = mode;

+ 1 - 1
iZpl/src/main/java/de/nplusc/izc/iZpl/API/PlaybackPlugin.java

@@ -19,7 +19,7 @@ package de.nplusc.izc.iZpl.API;
 import de.nplusc.izc.iZpl.API.shared.PlayListItem;
 
 /**
- *
+ * Additional requirements for Playback-Plugins. Playback-Plugins can either interface to a external player or implement playback themselves
  * @author iZc <nplusc.de>
  */
 public interface PlaybackPlugin extends Plugin

+ 1 - 1
iZpl/src/main/java/de/nplusc/izc/iZpl/API/Plugin.java

@@ -18,7 +18,7 @@
 package de.nplusc.izc.iZpl.API;
 
 /**
- *
+ * Minimal Methods required by any plugin
  * @author iZc <nplusc.de>
  */
 public interface Plugin

+ 56 - 11
iZpl/src/main/java/de/nplusc/izc/iZpl/API/PluginManager.java

@@ -40,7 +40,7 @@ import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import org.yaml.snakeyaml.Yaml;
 /**
- *
+ * API class for handling the Plugin related stuff
  * @author iZc <nplusc.de>
  */
 public class PluginManager
@@ -81,6 +81,10 @@ public class PluginManager
     
     private int uimodestate=Main.UIMODE_NONE; //X
     
+    /**
+     * Internal method used by the Bootstrapping code
+     * @param stts CommandLine status object
+     */
     @SuppressWarnings("element-type-mismatch")
     public void initializePlugins(CommandLineStatus stts)
     {
@@ -225,7 +229,10 @@ public class PluginManager
         }
 
     }
-
+    
+    /**
+     * Another internal method
+     */
     public void pluginInitCore()
     {
         if(pluginsAlreadyLoaded)
@@ -317,7 +324,11 @@ public class PluginManager
             }
         }
     }
-
+    /**
+     * Requests all currently installed Feature plugins
+     * @param requireUI set to true when the plugin has to support a UI mode
+     * @return List of the Plugin IDs
+     */
     public  List<String> getAvailableFeaturePlugins(boolean requireUI)
     {
         List<String> pluginsAvailable = new ArrayList<>();
@@ -329,17 +340,28 @@ public class PluginManager
         }
         return pluginsAvailable;
     }
-
+    
+    /**
+     * Returns the currently loaded Skin File
+     * @return Path to current skin
+     */
     public String getSelectedSkinPath()
     {
         return selectedSkinPath;
     }
-
+    
+    /**
+     * Updates the skin to the new path
+     * @param selectedSkinPath New Skin to install
+     */
     public void setSelectedSkinPath(String selectedSkinPath)
     {
         this.selectedSkinPath = selectedSkinPath;
     }
     
+    /**
+     * Internal method that updates the list of installed skins
+     */
     public static void detectSkins()
     {
         new File(IZPLApi.SKINPATH).mkdirs();
@@ -350,36 +372,59 @@ public class PluginManager
         detectedSkins.addAll(Arrays.asList(skinsAvailable));
     }
 
+    /**
+     * gets the currently active Playback-Plugin
+     * @return currently active Plugin
+     */
     public PlaybackPlugin getSelectedPlaybackPlugin()
     {
         return selectedPlaybackPlugin;
     }
-
+    /**
+     * gets the currently active UI-Plugin
+     * @return currently active Plugin
+     */
     public UIPlugin getSelectedUIPlugin()
     {
         return selectedUIPlugin;
     }
-
+    /**
+     * gets the currently active Feature-Plugin
+     * @return currently active Plugin
+     */
     public FeaturePlugin getSelectedFeaturePlugin()
     {
         return selectedFeaturePlugin;
     }
-
+    
+    /**
+     * gets all available UI-Plugins
+     * @return List with the plugins
+     */
     List<UIPlugin> getRegisteredUIs()
     {
         return registeredUIs;
     }
-
+    /**
+     * gets all available Playback-Plugins
+     * @return List with the plugins
+     */
     public List<PlaybackPlugin> getRegisteredPlayBackAdapters()
     {
         return registeredPlayBackAdapters;
     }
-
+        /**
+     * gets all available Feature-Plugins
+     * @return List with the plugins
+     */
     public List<FeaturePlugin> getRegisteredFeatures()
     {
         return registeredFeatures;
     }
-
+    /**
+     * gets all available Skins
+     * @return List with the plugins
+     */
     public static List<String> getDetectedSkins()
     {
         return detectedSkins;

+ 1 - 1
iZpl/src/main/java/de/nplusc/izc/iZpl/API/ProgressWindow.java

@@ -20,7 +20,7 @@ package de.nplusc.izc.iZpl.API;
 import de.nplusc.izc.iZpl.GUI.DoubleBar;
 
 /**
- *
+ * API class to allow access to the default Progress bar module
  * @author iZc <nplusc.de>
  */
 public class ProgressWindow

+ 6 - 1
iZpl/src/main/java/de/nplusc/izc/iZpl/API/SkinnableUIPlugin.java

@@ -18,10 +18,15 @@
 package de.nplusc.izc.iZpl.API;
 
 /**
- *
+ * Additional Methods required by UIPlugins that support custom skins
  * @author iZc <nplusc.de>
  */
 public interface SkinnableUIPlugin extends UIPlugin
 {
+    /**
+     * Checks wheter the given skin (which has to be a valid installed skin) is compatible with the selected UI-Plugin
+     * @param skinName Name of the registered skin
+     * @return true when the skin is compatible
+     */
     public boolean isSkinCompatible(String skinName);
 }

+ 1 - 1
iZpl/src/main/java/de/nplusc/izc/iZpl/API/UIPlugin.java

@@ -20,7 +20,7 @@ package de.nplusc.izc.iZpl.API;
 import java.awt.Image;
 
 /**
- *
+ * UI-Plugins define how the interface of the Software looks in the core functions
  * @author iZc <nplusc.de>
  */
 public interface UIPlugin extends Plugin

+ 87 - 26
iZpl/src/main/java/de/nplusc/izc/iZpl/Main.java

@@ -53,17 +53,35 @@ import org.yaml.snakeyaml.Yaml;
  */
 @SuppressWarnings("CallToPrintStackTrace")
 public class Main extends javax.swing.JFrame
-{
-    private static PluginManager p = new PluginManager();
-    private static Logger l;
-    private static final String jarschiv = Main.class.getProtectionDomain().getCodeSource().getLocation().getPath();
+{   
+    /**
+     * convenience object
+     */
+     public static final Yaml y = new Yaml();
+     
+     /**
+      * COnstant to get the config file path
+      */
     public static final String CONFIGPATH = IZPLApi.APPDIR + File.separator + "config" + File.separator + "config.yml";
-    public static final Yaml y = new Yaml();
+   
+    
+    /**
+     * Constants for the different UImodes
+     */
     public static final int UIMODE_NONE=0,UIMODE_OLD=1,UIMODE_NEW=2;
+    
+    /**
+     * Reference to the configuration holder Object
+     */
+    public static Configuration CONFIG;
+    
+    private static PluginManager p = new PluginManager();
+    private static Logger l;
+
     private static boolean loadedVLC = false;
     private static PLServer ps = null;
     private static boolean issueDetected = false;
-    public static Configuration CONFIG;
+    
     private static CommandLineStatus stts;
     private static FirstRunScreen frs;
     
@@ -72,6 +90,7 @@ public class Main extends javax.swing.JFrame
     
     // <editor-fold defaultstate="collapsed" desc="Gefruzel::Main">    
     /**
+     * Main entrypoint where the Program starts
      * @param args the command line arguments
      */
     @SuppressWarnings(
@@ -130,7 +149,7 @@ public class Main extends javax.swing.JFrame
         }
     }
 
-    public static void logStart()
+    private static void logStart()
     {
         if(l==null)
             l=LogManager.getLogger(Main.class.getName());
@@ -140,12 +159,8 @@ public class Main extends javax.swing.JFrame
         Runtime.getRuntime().addShutdownHook(new Shitdown());
     }
     
-    public static void setupLogging(boolean verbose)
+    static void setupLogging(boolean verbose)
     {
-        //if(!cl.hasOption("verbose")&&!(System.getProperty("log4j.configurationFile")==null))
-        //{
-        //    System.setProperty("log4j.configurationFile", "file:///"+jarschiv+"!log4j2NonVerbose.xml");
-        //}
         l=LogManager.getLogger(Main.class.getName());
         LoggerContext cx = (LoggerContext) LogManager.getContext(false);
         org.apache.logging.log4j.core.config.Configuration config = cx.getConfiguration();
@@ -169,6 +184,17 @@ public class Main extends javax.swing.JFrame
     
     
     // </editor-fold> 
+    /**
+     * Internal method used by the MEnu UI to resume initializing
+     * @param pFfilemode
+     * @param pStatemode 
+     * @param pFile iZpl-file to load
+     * @param pForcePregen Switch that tells iZpl to pregenerate a Playlist instead of using the normal mode
+     * @param pBurnDisc switch for the currently unused Disk burn mode
+     * @param pLoadConfigMode switch to show the config UI
+     * @param pFeatureMode switch to enable loading of featurePlugin
+     * @param pFeaturePluginID ID of the featureplugin that gets used
+     */
     public static void UIMain(boolean pFfilemode,boolean pStatemode,String pFile,boolean pForcePregen,
             boolean pBurnDisc,boolean pLoadConfigMode,boolean pFeatureMode,String pFeaturePluginID)
     {
@@ -191,7 +217,7 @@ public class Main extends javax.swing.JFrame
         mainProcessing();
     }
     
-    public static void spawnUI()
+    static void spawnUI()
     {
         p.pluginInitCore(); //sorgt dafür dass plugins bereits registriert sind
         EventQueue.invokeLater(()->{
@@ -249,7 +275,7 @@ public class Main extends javax.swing.JFrame
         l.info("Initializing the plugins now. This may take a while");
         p.initializePlugins(stts);
         l.info("Plugins initialized");
-            //TODO:  GUI-Editor zum Erzeugen von iZpl-S
+            //TODO:  GUI-Editor zum Erzeugen von iZpl-S; TODO: preserve other comments in M3u
         mainProcessingStage2();
     }
 
@@ -375,7 +401,7 @@ public class Main extends javax.swing.JFrame
 
     private static void startup()
     {
-        String time = "";
+        String time = "";//throw new CodeStatusError("404");
 
         time = new Date(System.currentTimeMillis()).toString();
         l.info("IZPL-Core:initialized at:" + time);
@@ -401,7 +427,7 @@ public class Main extends javax.swing.JFrame
             if (
                     (stts.filemode && !(stts.forcePregen || isShittyPlayer))                      ||
                     (stts.featurePluginMode&&p.getSelectedFeaturePlugin().requiresLoadedPlayList()))
-            {  //throw new CodeStatusError("404");
+            {  
                 l.trace("usegui=" + stts.useGUI);
                 l.trace("featurePlugin=" + stts.featurePluginMode);
                 
@@ -564,7 +590,10 @@ public class Main extends javax.swing.JFrame
         l.trace("usegui=" + stts.useGUI);
         ps = new PLServer(pp, !stts.useGUI);
     }
-
+    /**
+     * Triggers a save of the state then exiting the program
+     * @param isShittyPlayer parameter that tells if the Program detected a player incompatible with the pregeneration mode
+     */
     public static void checkpointedExit(boolean isShittyPlayer)
     {
         l.trace("<<<");
@@ -579,7 +608,9 @@ public class Main extends javax.swing.JFrame
         }
         quickQuit();
     }
-    
+    /**
+     * Convenience method that cleans up the temporary data and then exits
+     */
     public static void quickQuit()
     {
         TFile killme = new TFile(IZPLApi.TEMPDIR);
@@ -626,45 +657,75 @@ public class Main extends javax.swing.JFrame
         pack();
     }// </editor-fold>//GEN-END:initComponents
 
-    public Main()
+    Main()
     {
         initComponents();
     }
+    
+     //V--nothing to see here
+    
+    //^--evil line doesnt need any code :P
+    /**
+     * Internal method for the API
+     * @return 
+     */
     public static PLServer getPLServer()
     {
         return ps;
     }
+    /**
+     * Internal method for the API
+     * @return 
+     */
     public static void gotAIssue()
     {
         gotAIssue(true);
     }
+    /**
+     * Internal method for the API
+     * @return 
+     */
     public static void gotAIssue(boolean issue)
     {
         issueDetected = issue;
     }
+    /**
+     * Internal method for the API
+     * @return 
+     */
     public static Image getPlayListIcon()
     {
         return playListIcon;
     }
+    /**
+     * Internal method for the API
+     * @return 
+     */
     public static boolean isFilemode()
     {
         return stts.filemode;
     }
-
+    /**
+     * Internal method for the API
+     * @return 
+     */
     public static boolean isStatefile()
     {
         return stts.statefile;
     }
-
+    /**
+     * Internal method for the API
+     * @return 
+     */
     public static CommandLineStatus getStts()
     {
         return stts;
     }
-
-    
-    //V--nothing to see here
     
-    //^--evil line doesnt need any code :P
+    /**
+     * Internal method for the API
+     * @return 
+     */
     public static PluginManager getPluginManager()
     {
         return p;
@@ -713,6 +774,6 @@ public class Main extends javax.swing.JFrame
      * V0.6.0.0 Editor basics, Bugfixxes & rewrite of the Reader code whic resides now in PLFileIO.java 
      * V0.7.0.0 Refactor of the main class to shrink it
      * V0.7.1.0 Fixes
-     * V0.8.0.0 Stream support, fix related to a error message,
+     * V0.8.0.0 Stream support, fix related to a error message, Refactors and code documentation
      */
 }

+ 0 - 8
iZpl/src/main/java/de/nplusc/izc/iZpl/PlProcessorV2.java

@@ -232,14 +232,6 @@ public class PlProcessorV2 implements HttpHandler
         String time = new Date(System.currentTimeMillis()).toString();
         l.info("IZPL-HAndler:Received Request at:"+time);
          String response = "Nixda mit glotzen...\n Hier gibts keine Filezzzzzzz, also raus und zwar dalli";
-       /* if(!t.getRemoteAddress().getHostName().equalsIgnoreCase("localhost"))
-        {
-        t.sendResponseHeaders(403, response.length());
-        OutputStream os = t.getResponseBody();
-        os.write(response.getBytes());
-        os.close();
-        return;
-        }*/
         response = "#EXTM3U";
                 //  \N am anfang jeder zeile....
         String tr = getBlock();

+ 17 - 8
iZpl/src/main/java/de/nplusc/izc/iZpl/Utils/VlcInterface.java

@@ -303,6 +303,22 @@ public class VlcInterface implements PlaybackPlugin , MediaPlayerEventListener
     @Override
     public void finished(MediaPlayer mp)
     {
+        finished(false);
+    }
+    
+    public void finished(boolean skip)
+    {
+        try
+        {
+            if(!skip)
+            {
+                Thread.sleep(2000);
+            }
+        }
+        catch (InterruptedException ex)
+        {
+            ex.printStackTrace();
+        }
         if(isInMultiItem)
         {
             skipTitle();
@@ -313,10 +329,7 @@ public class VlcInterface implements PlaybackPlugin , MediaPlayerEventListener
             PlayListItem next = IZPLApi.getNextItem();
             setTitleToPlay(next);
         }
-        
-        //TODO CODE
     }
-    
     @Override
     public void timeChanged(MediaPlayer mp, long l)
     {
@@ -509,7 +522,7 @@ public class VlcInterface implements PlaybackPlugin , MediaPlayerEventListener
         @Override
         public void skipTitle()
         {
-            parent.finished(mpaccess);//über bande spielen
+            parent.finished(true);//über bande spielen
         }
 
         @Override
@@ -586,10 +599,6 @@ public class VlcInterface implements PlaybackPlugin , MediaPlayerEventListener
                 ex.printStackTrace();
             }
         }
-        else
-        {
-            l.warn("");
-        }
     };