]> git.sesse.net Git - vlc/blobdiff - bindings/java/core/src/main/java/org/videolan/jvlc/JVLC.java
MediaInstance renamed to MediaPlayer
[vlc] / bindings / java / core / src / main / java / org / videolan / jvlc / JVLC.java
index 1d089c1566e4a96ba67d736a7f5190331c3a2da1..6c826234a1961616a5627e0a0c93cb05bfbbcafa 100644 (file)
@@ -46,7 +46,9 @@ public class JVLC
 
     private MediaList mediaList;
     
-    private volatile boolean released; 
+    private VLM vlm;
+    
+    private volatile boolean released;
     
     public JVLC()
     {
@@ -65,11 +67,21 @@ public class JVLC
         this(args.split(" "));
     }
 
-    public MediaInstance play(String media)
+    /*
+     * Core methods
+     */
+    private LibVlcInstance createInstance(String[] args)
+    {
+        libvlc_exception_t exception = new libvlc_exception_t();
+        return libvlc.libvlc_new(args.length, args, exception);
+    }
+
+    public MediaPlayer play(String media)
     {
         MediaDescriptor mediaDescriptor = new MediaDescriptor(this, media);
-        MediaInstance mediaInstance = new MediaInstance(mediaDescriptor);
+        MediaPlayer mediaInstance = new MediaPlayer(mediaDescriptor);
         mediaInstance.play();
+        mediaDescriptor.release();
         return mediaInstance;
     }
 
@@ -80,20 +92,28 @@ 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()
     {
-        libvlc_exception_t exception = new libvlc_exception_t();
-        libvlc.libvlc_exception_init(exception);
-
-        return libvlc.libvlc_new(args.length, args, exception);
+        return mediaList;
     }
 
-    public Logger getLogger()
+    public VLM getVLM()
     {
-        return new Logger(this);
+        if (vlm != null)
+        {
+            vlm.release();
+        }
+        this.vlm = new VLM(this);
+        return vlm;
     }
     
     public LoggerVerbosityLevel getLogVerbosity()
@@ -133,11 +153,17 @@ public class JVLC
      */
     public void release()
     {
-        if (!released)
+        if (released)
         {
-            released = true;
-            libvlc.libvlc_release(instance);
+            return;
         }
+        released = true;
+        if (vlm != null)
+        {
+            vlm.release();
+            vlm = null;
+        }
+        libvlc.libvlc_release(instance);
     }
 
     /*
@@ -147,21 +173,8 @@ public class JVLC
     @Override
     protected void finalize() throws Throwable
     {
-        if (!released)
-        {
-            released = true;
-            libvlc.libvlc_release(instance);
-        }
+        release();
         super.finalize();
     }
     
-    /**
-     * Returns the mediaList.
-     * @return the mediaList
-     */
-    public MediaList getMediaList()
-    {
-        return mediaList;
-    }
-    
 }