private MediaList mediaList;
+ private VLM vlm;
+
+ private volatile boolean released;
+
public JVLC()
{
String[] args = new String[] {};
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;
}
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()
{
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)
@Override
protected void finalize() throws Throwable
{
- libvlc.libvlc_release(instance);
+ release();
super.finalize();
}
- /**
- * Returns the mediaList.
- * @return the mediaList
- */
- public MediaList getMediaList()
- {
- return mediaList;
- }
-
}