]> git.sesse.net Git - vlc/blobdiff - bindings/java/core/src/main/java/org/videolan/jvlc/JVLC.java
minor changes to JVLC class
[vlc] / bindings / java / core / src / main / java / org / videolan / jvlc / JVLC.java
index 5d4d9c7453410e4f6bf2eac9c1b80d36f3f93ded..23dcfebcf82d87ac244b21d6689e3f55be8b6faf 100644 (file)
@@ -46,6 +46,10 @@ public class JVLC
 
     private MediaList mediaList;
     
+    private VLM vlm;
+    
+    private volatile boolean released;
+    
     public JVLC()
     {
         String[] args = new String[] {};
@@ -63,11 +67,21 @@ public class JVLC
         this(args.split(" "));
     }
 
+    /*
+     * Core methods
+     */
+    private LibVlcInstance createInstance(String[] args)
+    {
+        libvlc_exception_t exception = new libvlc_exception_t();
+        return libvlc.libvlc_new(args.length, args, exception);
+    }
+
     public MediaInstance play(String media)
     {
         MediaDescriptor mediaDescriptor = new MediaDescriptor(this, media);
         MediaInstance mediaInstance = new MediaInstance(mediaDescriptor);
         mediaInstance.play();
+        mediaDescriptor.release();
         return mediaInstance;
     }
 
@@ -78,17 +92,44 @@ public class JVLC
         libvlc.libvlc_video_set_parent(instance, drawable, exception );
     }
 
-    /*
-     * Core methods
+    public Logger getLogger()
+    {
+        return new Logger(this);
+    }
+    
+    /**
+     * Returns the mediaList.
+     * @return the mediaList
      */
-    private LibVlcInstance createInstance(String[] args)
+    public MediaList getMediaList()
+    {
+        return mediaList;
+    }
+
+    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();
-        libvlc.libvlc_exception_init(exception);
+        int level = libvlc.libvlc_get_log_verbosity(instance, exception);
+        return LoggerVerbosityLevel.getSeverity(level);
+    }
 
-        return libvlc.libvlc_new(args.length, args, exception);
+    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
@@ -106,6 +147,24 @@ public class JVLC
     {
         return libvlc;
     }
+    
+    /**
+     * Releases this instance and the native resources.
+     */
+    public void release()
+    {
+        if (released)
+        {
+            return;
+        }
+        released = true;
+        if (vlm != null)
+        {
+            vlm.release();
+            vlm = null;
+        }
+        libvlc.libvlc_release(instance);
+    }
 
     /*
      * (non-Javadoc)
@@ -114,17 +173,8 @@ public class JVLC
     @Override
     protected void finalize() throws Throwable
     {
-        libvlc.libvlc_release(instance);
+        release();
         super.finalize();
     }
     
-    /**
-     * Returns the mediaList.
-     * @return the mediaList
-     */
-    public MediaList getMediaList()
-    {
-        return mediaList;
-    }
-    
 }