Commit 6a84cf10 authored by Filippo Carone's avatar Filippo Carone

java audio interface update

parent 7d6ea0b1
...@@ -6,52 +6,78 @@ import org.videolan.jvlc.VLCException; ...@@ -6,52 +6,78 @@ import org.videolan.jvlc.VLCException;
public class VLCExample public class VLCExample
{ {
public static void main( String[] args ) public static void main(String[] args) throws InterruptedException
{ {
System.out.println("== Starting VLCExample ==");
boolean videoInput = false; boolean videoInput = false;
if (args.length == 0)
{
System.out.print("Creating a JVLC instance without args");
}
else
{
System.out.println("Creating a JVLC instance with args: ");
for (int i = 0; i < args.length; i++)
{
System.out.println(i + ") " + args[i]);
}
}
JVLC jvlc = new JVLC(args); JVLC jvlc = new JVLC(args);
try { System.out.println("... done.");
//jvlc.playlist.add("file://" + System.getProperty( "user.dir" ) + "/a.avi", "a.avi");
try
{
// jvlc.playlist.add("file://" + System.getProperty( "user.dir" ) + "/a.avi", "a.avi");
jvlc.playlist.add("file:///home/little/a.avi", "a.avi"); jvlc.playlist.add("file:///home/little/a.avi", "a.avi");
jvlc.playlist.add("file://" + System.getProperty( "user.dir" ) + "/a.mp3", "a.mp3"); // jvlc.playlist.add("file://" + System.getProperty( "user.dir" ) + "/a.mp3", "a.mp3");
jvlc.playlist.play( -1 , null ); jvlc.playlist.play(-1, null);
} catch (VLCException e) { }
catch (VLCException e)
{
e.printStackTrace(); e.printStackTrace();
} }
while (! jvlc.isInputPlaying()) ;
while (! jvlc.hasVout() );
while (! jvlc.isInputPlaying())
{
Thread.sleep(100);
}
while (! jvlc.hasVout() )
{
Thread.sleep(100);
}
// testing vout functionalities // testing vout functionalities
try {
Thread.sleep(2500); Thread.sleep(2500);
if (jvlc.hasVout()) videoInput = true; if (jvlc.hasVout())
} catch (InterruptedException e) { {
e.printStackTrace(); videoInput = true;
} }
if (videoInput) { if (videoInput)
try { {
try
{
System.out.print(jvlc.video.getWidth()); System.out.print(jvlc.video.getWidth());
System.out.print("x"); System.out.print("x");
System.out.println(jvlc.video.getHeight()); System.out.println(jvlc.video.getHeight());
} catch (VLCException e) { }
catch (VLCException e)
{
e.printStackTrace(); e.printStackTrace();
} }
} }
try try
{ {
if (videoInput) { if (videoInput)
{
System.out.print("Fullscreen... "); System.out.print("Fullscreen... ");
jvlc.video.setFullscreen(true); jvlc.video.setFullscreen(true);
Thread.sleep(3000); Thread.sleep(3000);
System.out.println("real size."); System.out.println("real size.");
jvlc.video.setFullscreen(false); jvlc.video.setFullscreen(false);
System.out.print("Taking snapshot... "); System.out.print("Taking snapshot... ");
jvlc.video.getSnapshot( System.getProperty( "user.dir" ) + "/snap.png"); jvlc.video.getSnapshot(System.getProperty("user.dir") + "/snap.png");
System.out.println("taken. (see " + System.getProperty( "user.dir" ) + "/snap.png )"); System.out.println("taken. (see " + System.getProperty("user.dir") + "/snap.png )");
Thread.sleep(2000); Thread.sleep(2000);
System.out.println("Resizing to 300x300"); System.out.println("Resizing to 300x300");
jvlc.video.setSize(300, 300); jvlc.video.setSize(300, 300);
...@@ -67,16 +93,22 @@ public class VLCExample ...@@ -67,16 +93,22 @@ public class VLCExample
System.out.print("Setting volume to 150... "); System.out.print("Setting volume to 150... ");
jvlc.audio.setVolume(150); jvlc.audio.setVolume(150);
System.out.println("done"); System.out.println("done");
// System.out.println("Audio channel info: " + jvlc.audio.getChannel()); System.out.println("== AUDIO INFO ==");
// System.out.println("Audio track info: " + jvlc.audio.getTrack()); int currentChannel = jvlc.audio.getChannel();
// System.out.print("Setting left channel... "); System.out.println("Audio track number: " + jvlc.audio.getTrack());
// jvlc.audio.setChannel("left"); System.out.println("Audio channel info: " + jvlc.audio.getChannel());
// System.out.print("done."); System.out.print("Setting left channel... ");
// Thread.sleep(3000); jvlc.audio.setChannel(AudioIntf.LEFT_CHANNEL);
// System.out.print("Setting right channel... "); System.out.println("done.");
// jvlc.audio.setChannel(AudioIntf.RIGHT_CHANNEL); Thread.sleep(3000);
// System.out.print("done."); System.out.print("Setting right channel... ");
// Thread.sleep(3000); jvlc.audio.setChannel(AudioIntf.RIGHT_CHANNEL);
System.out.println("done.");
Thread.sleep(3000);
System.out.print("Reverting to original channel");
jvlc.audio.setChannel(currentChannel);
System.out.println("done.");
Thread.sleep(3000);
System.out.println("INPUT INFORMATION"); System.out.println("INPUT INFORMATION");
System.out.println("-----------------"); System.out.println("-----------------");
System.out.println("Total length (ms) :\t" + jvlc.input.getLength()); System.out.println("Total length (ms) :\t" + jvlc.input.getLength());
...@@ -85,7 +117,6 @@ public class VLCExample ...@@ -85,7 +117,6 @@ public class VLCExample
if (videoInput) if (videoInput)
System.out.println("Input FPS :\t" + jvlc.input.getFPS()); System.out.println("Input FPS :\t" + jvlc.input.getFPS());
} }
catch (Exception e) catch (Exception e)
...@@ -98,19 +129,18 @@ public class VLCExample ...@@ -98,19 +129,18 @@ public class VLCExample
System.out.println("Everything fine ;)"); System.out.println("Everything fine ;)");
System.out.println("Playing next item"); System.out.println("Playing next item");
try { try
{
jvlc.playlist.next(); jvlc.playlist.next();
} catch (VLCException e) { }
catch (VLCException e)
{
e.printStackTrace(); e.printStackTrace();
} }
try {
Thread.sleep(3000); Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
jvlc.destroy(); jvlc.destroy();
return; return;
} }
} }
...@@ -35,25 +35,25 @@ public interface AudioIntf { ...@@ -35,25 +35,25 @@ public interface AudioIntf {
/** /**
* Constant for left channel audio * Constant for left channel audio
*/ */
final String LEFT_CHANNEL = "left"; final int LEFT_CHANNEL = 3;
/** /**
* Constant for right channel audio * Constant for right channel audio
*/ */
final String RIGHT_CHANNEL = "right"; final int RIGHT_CHANNEL = 4;
/** /**
* Constant for reverse channel audio * Constant for reverse channel audio
*/ */
final String REVERSE_CHANNEL = "reverse"; final int REVERSE_CHANNEL = 2;
/** /**
* Constant for stereo channel audio * Constant for stereo channel audio
*/ */
final String STEREO_CHANNEL = "stereo"; final int STEREO_CHANNEL = 1;
/** /**
* Constant for dolby channel audio * Constant for dolby channel audio
*/ */
final String DOLBY_CHANNEL = "dolby"; final int DOLBY_CHANNEL = 5;
/** /**
* @return audio track * @return audio track
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment