]> git.sesse.net Git - vlc/blobdiff - bindings/java/core/src/main/java/org/videolan/jvlc/JVLC.java
VLM class almost done
[vlc] / bindings / java / core / src / main / java / org / videolan / jvlc / JVLC.java
index 7ffaa18e0eb6be403a23982cd617c5338d5ab5eb..32cf17988873986865e52b2ea76acc9956b4e2b0 100644 (file)
 
 package org.videolan.jvlc;
 
+import java.awt.Canvas;
+
 import org.videolan.jvlc.internal.LibVlc;
 import org.videolan.jvlc.internal.LibVlc.LibVlcInstance;
 import org.videolan.jvlc.internal.LibVlc.libvlc_exception_t;
 
 import com.sun.jna.Native;
 
-import java.awt.Canvas;
-
 public class JVLC
 {
 
     private final LibVlcInstance instance;
 
     private final LibVlc libvlc = LibVlc.SYNC_INSTANCE;
+
+    private MediaList mediaList;
+    
+    private VLM vlm;
+    
+    private volatile boolean released; 
     
     public JVLC()
     {
-        String[] args = new String[1];
-        args[0] = "jvlc";
+        String[] args = new String[] {};
         instance = createInstance(args);
+        mediaList = new MediaList(this);
     }
 
     public JVLC(String[] args)
     {
-        String[] myargs = new String[args.length + 1];
-        myargs[0] = "jvlc";
-        System.arraycopy(args, 0, myargs, 1, args.length);
-        instance = createInstance(myargs);
+        instance = createInstance(args);
+    }
+    
+    public JVLC(String args)
+    {
+        this(args.split(" "));
     }
 
     public MediaInstance play(String media)
@@ -85,6 +93,35 @@ public class JVLC
         return libvlc.libvlc_new(args.length, args, exception);
     }
 
+    public Logger getLogger()
+    {
+        return new Logger(this);
+    }
+    
+    public VLM getVLM()
+    {
+        if (vlm != null)
+        {
+            vlm.release();
+        }
+        this.vlm = new VLM(this);
+        return vlm;
+    }
+    
+    public LoggerVerbosityLevel getLogVerbosity()
+    {
+        libvlc_exception_t exception = new libvlc_exception_t();
+        int level = libvlc.libvlc_get_log_verbosity(instance, exception);
+        return LoggerVerbosityLevel.getSeverity(level);
+    }
+
+    public void setLogVerbosity(LoggerVerbosityLevel level)
+    {
+        libvlc_exception_t exception = new libvlc_exception_t();
+        libvlc.libvlc_set_log_verbosity(instance, level.ordinal(), exception);
+    }
+
+    
     /**
      * Returns the _instance.
      * @return the _instance
@@ -102,6 +139,23 @@ public class JVLC
     {
         return libvlc;
     }
+    
+    /**
+     * Releases this instance and the native resources.
+     */
+    public void release()
+    {
+        if (!released)
+        {
+            released = true;
+            if (vlm != null)
+            {
+                vlm.release();
+                vlm = null;
+            }
+            libvlc.libvlc_release(instance);
+        }
+    }
 
     /*
      * (non-Javadoc)
@@ -110,7 +164,21 @@ public class JVLC
     @Override
     protected void finalize() throws Throwable
     {
-        libvlc.libvlc_release(instance);
+        if (!released)
+        {
+            released = true;
+            libvlc.libvlc_release(instance);
+        }
         super.finalize();
     }
+    
+    /**
+     * Returns the mediaList.
+     * @return the mediaList
+     */
+    public MediaList getMediaList()
+    {
+        return mediaList;
+    }
+    
 }