1 /*****************************************************************************
2 * JVLC.java: Main Java Class, represents a libvlc_instance_t object
3 *****************************************************************************
5 * Copyright (C) 1998-2006 the VideoLAN team
7 * Author: Filippo Carone <filippo@carone.org>
8 * Philippe Morin <phmorin@free.fr>
10 * Created on 28-feb-2006
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.
31 package org.videolan.jvlc;
33 public class JVLC implements Runnable {
36 System.loadLibrary("jvlc" );
40 * These are set as final since they live along the jvlc object
42 private final long _instance;
44 public final Playlist playlist;
45 public final Video video;
46 public final Audio audio;
47 public final Input input;
50 private boolean beingDestroyed = false;
53 * This is the time in millis VLC checks for internal status
55 private long resolution = 50;
57 private boolean inputPlaying = false;
58 private boolean inputVout = false;
61 String[] args = new String[1];
64 _instance = createInstance( args );
65 playlist = new Playlist ( _instance );
66 video = new Video ( _instance );
67 audio = new Audio ( _instance );
68 input = new Input ( _instance );
69 vlm = new VLM ( _instance );
70 new Thread(this).start();
73 public JVLC(String[] args) {
74 String[] myargs = new String[args.length + 1];
76 System.arraycopy( args, 0, myargs, 1, args.length );
77 _instance = createInstance( myargs );
78 playlist = new Playlist ( _instance );
79 video = new Video ( _instance );
80 audio = new Audio ( _instance );
81 input = new Input ( _instance );
82 vlm = new VLM ( _instance );
84 new Thread(this).start();
89 * Destroys the current instance of jvlc, cleaning up objects.
90 * This is unreversible.
92 public void destroy() {
95 beingDestroyed = true;
104 private native long createInstance( String[] args );
105 private native void _destroy();
107 public long getInstance() throws VLCException {
112 * Getters and setters
114 public Playlist getPlaylist() throws VLCException {
121 * Checks if the input is playing.
122 * @return True if there is a playing input.
124 public boolean isInputPlaying() {
129 * Checks if the input has spawned a video window.
130 * @return True if there is a video window.
132 public boolean hasVout() {
138 * @see java.lang.Runnable#run()
140 * In this thread we check the playlist and input status.
144 while (!beingDestroyed) {
146 while (playlist.isRunning()) {
147 inputPlaying = input.isPlaying();
148 inputVout = input.hasVout();
149 Thread.sleep(resolution);
150 } // while playlist running
151 } catch (VLCException e) {
152 // it is non-sense to show the stacktrace here
153 // e.printStackTrace();
155 inputPlaying = false;
157 Thread.sleep(resolution);
158 } // while ! being destroyed
159 } catch (InterruptedException e) {
165 * @see java.lang.Object#finalize()
167 protected void finalize() throws Throwable {