1 /*****************************************************************************
2 * JVLC.java: Main Java Class, represents a libvlc_instance_t object
3 *****************************************************************************
5 * Copyright (C) 1998-2008 the VideoLAN team
7 * Author: Filippo Carone <filippo@carone.org>
8 * Philippe Morin <phmorin@free.fr>
10 * Created on 28-feb-2006
12 * $Id: JVLC.java 20141 2007-05-16 19:31:35Z littlejohn $
14 * This program is free software; you can redistribute it
15 * and/or modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2 of the
17 * License, or (at your option) any later version.
19 * This program is distributed in the hope that it will be useful, but
20 * WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 * General Public License for more details.
24 * You should have received a copy of the GNU General Public
25 * License along with this program; if not, write to the Free Software
26 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
30 package org.videolan.jvlc;
32 import java.awt.Canvas;
34 import org.videolan.jvlc.internal.LibVlc;
35 import org.videolan.jvlc.internal.LibVlc.LibVlcInstance;
36 import org.videolan.jvlc.internal.LibVlc.libvlc_exception_t;
38 import com.sun.jna.Native;
43 private final LibVlcInstance instance;
45 private final LibVlc libvlc = LibVlc.SYNC_INSTANCE;
47 private MediaList mediaList;
51 private volatile boolean released;
55 String[] args = new String[] {};
56 instance = createInstance(args);
57 mediaList = new MediaList(this);
60 public JVLC(String[] args)
62 instance = createInstance(args);
65 public JVLC(String args)
67 this(args.split(" "));
70 public MediaInstance play(String media)
72 MediaDescriptor mediaDescriptor = new MediaDescriptor(this, media);
73 MediaInstance mediaInstance = new MediaInstance(mediaDescriptor);
78 public void setVideoOutput(Canvas canvas)
80 long drawable = Native.getComponentID(canvas);
81 libvlc_exception_t exception = new libvlc_exception_t();
82 libvlc.libvlc_video_set_parent(instance, drawable, exception );
88 private LibVlcInstance createInstance(String[] args)
90 libvlc_exception_t exception = new libvlc_exception_t();
91 libvlc.libvlc_exception_init(exception);
93 return libvlc.libvlc_new(args.length, args, exception);
96 public Logger getLogger()
98 return new Logger(this);
107 this.vlm = new VLM(this);
111 public LoggerVerbosityLevel getLogVerbosity()
113 libvlc_exception_t exception = new libvlc_exception_t();
114 int level = libvlc.libvlc_get_log_verbosity(instance, exception);
115 return LoggerVerbosityLevel.getSeverity(level);
118 public void setLogVerbosity(LoggerVerbosityLevel level)
120 libvlc_exception_t exception = new libvlc_exception_t();
121 libvlc.libvlc_set_log_verbosity(instance, level.ordinal(), exception);
126 * Returns the _instance.
127 * @return the _instance
129 LibVlcInstance getInstance()
135 * Returns the libvlc.
144 * Releases this instance and the native resources.
146 public void release()
156 libvlc.libvlc_release(instance);
162 * @see java.lang.Object#finalize()
165 protected void finalize() throws Throwable
170 libvlc.libvlc_release(instance);
176 * Returns the mediaList.
177 * @return the mediaList
179 public MediaList getMediaList()