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>
9 * Created on 28-feb-2006
13 * This program is free software; you can redistribute it
14 * and/or modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2 of the
16 * License, or (at your option) any later version.
18 * This program is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * General Public License for more details.
23 * You should have received a copy of the GNU General Public
24 * License along with this program; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
30 package org.videolan.jvlc;
36 public class JVLC implements JLibVLC, Runnable {
39 System.load(System.getProperty( "user.dir" ) + "/libjvlc.so" );
43 * These are set as final since they live along the jvlc object
45 private final long _instance;
46 public final Playlist playlist;
49 private boolean beingDestroyed = false;
50 private long resolution = 50;
51 private boolean inputPlaying = false;
52 private boolean inputVout = false;
55 _instance = createInstance();
56 playlist = new Playlist( _instance );
57 new Thread(this).start();
60 public JVLC(String[] args) {
61 _instance = createInstance( args );
62 playlist = new Playlist( _instance );
63 new Thread(this).start();
68 * Destroys the current instance of jvlc, cleaning up objects.
69 * This is unreversible.
71 public void destroy() {
72 beingDestroyed = true;
80 private native long createInstance();
81 private native long createInstance( String[] args );
82 private native void _destroy();
84 * Audio native methods
86 private native boolean _getMute();
87 private native void _setMute( boolean value );
88 private native void _toggleMute();
89 private native int _getVolume();
90 private native void _setVolume( int volume );
93 * Input native methods
95 private native long _getInputLength();
96 private native float _getInputPosition();
97 private native long _getInputTime();
98 private native float _getInputFPS();
102 * Video native methods
104 private native void _toggleFullscreen();
105 private native void _setFullscreen( boolean value);
106 private native boolean _getFullscreen();
107 private native int _getVideoHeight();
108 private native int _getVideoWidth();
109 private native void _getSnapshot(String filename);
112 public boolean getMute() {
116 public void setMute(boolean value) {
121 public void toggleMute() {
125 public int getVolume() {
129 public void setVolume(int volume) {
130 _setVolume( volume );
134 public void toggleFullscreen() {
139 public void setFullscreen( boolean value ) {
140 _setFullscreen( value );
144 public boolean getFullscreen() {
145 return _getFullscreen();
148 public int getVideoHeight() {
149 return _getVideoHeight();
153 public int getVideoWidth() {
154 return _getVideoWidth();
158 public long getInputLength() {
159 return _getInputLength();
162 public long getInputTime() {
163 return _getInputTime();
166 public float getInputPosition() {
167 return _getInputPosition();
171 public void setInputTime() {
172 // TODO Auto-generated method stub
176 public double getInputFPS() {
177 return _getInputFPS();
180 public long getInstance() {
185 * Getters and setters
187 public Playlist getPlaylist() {
192 public void getSnapshot(String filename) {
193 _getSnapshot(filename);
197 * Checks if the input is playing.
198 * @return True if there is a playing input.
200 public boolean isInputPlaying() {
205 * Checks if the input has spawned a video window.
206 * @return True if there is a video window.
208 public boolean hasVout() {
214 * @see java.lang.Runnable#run()
216 * In this thread we check the playlist and input status.
219 while (! beingDestroyed) {
220 while (playlist.isRunning()) {
221 if (playlist.inputIsPlaying()) {
225 inputPlaying = false;
228 if (playlist.inputHasVout()) {
235 Thread.sleep(resolution);
236 } catch (InterruptedException e) {
239 } // while playlist running
240 inputPlaying = false;
243 Thread.sleep(resolution);
244 } catch (InterruptedException e) {
247 } // while ! being destroyed