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;
34 public class JVLC implements Runnable {
37 System.loadLibrary("jvlc" );
41 * These are set as final since they live along the jvlc object
43 private final long _instance;
45 public final Playlist playlist;
46 public final Video video;
47 public final Audio audio;
48 public final Input input;
51 private boolean beingDestroyed = false;
54 * This is the time in millis VLC checks for internal status
56 private long resolution = 50;
58 private boolean inputPlaying = false;
59 private boolean inputVout = false;
62 String[] args = new String[1];
65 _instance = createInstance( args );
66 playlist = new Playlist ( _instance );
67 video = new Video ( _instance );
68 audio = new Audio ( _instance );
69 input = new Input ( _instance );
70 vlm = new VLM ( _instance );
71 new Thread(this).start();
74 public JVLC(String[] args) {
75 _instance = createInstance( args );
76 playlist = new Playlist ( _instance );
77 video = new Video ( _instance );
78 audio = new Audio ( _instance );
79 input = new Input ( _instance );
80 vlm = new VLM ( _instance );
82 new Thread(this).start();
87 * Destroys the current instance of jvlc, cleaning up objects.
88 * This is unreversible.
90 public void destroy() {
91 beingDestroyed = true;
99 private native long createInstance( String[] args );
100 private native void _destroy();
102 public long getInstance() throws VLCException {
107 * Getters and setters
109 public Playlist getPlaylist() throws VLCException {
116 * Checks if the input is playing.
117 * @return True if there is a playing input.
119 public boolean isInputPlaying() {
124 * Checks if the input has spawned a video window.
125 * @return True if there is a video window.
127 public boolean hasVout() {
133 * @see java.lang.Runnable#run()
135 * In this thread we check the playlist and input status.
138 while (! beingDestroyed) {
140 while (playlist.isRunning()) {
141 if (input.isPlaying()) {
145 inputPlaying = false;
148 if (input.hasVout()) {
155 Thread.sleep(resolution);
156 } catch (InterruptedException e) {
160 } catch (VLCException e1) { } // while playlist running
161 inputPlaying = false;
164 Thread.sleep(resolution);
165 } catch (InterruptedException e) {
168 } // while ! being destroyed