]> git.sesse.net Git - vlc/blob - bindings/java/VLCExample.java
Java bindings update.
[vlc] / bindings / java / VLCExample.java
1 import org.videolan.jvlc.JVLC;
2
3
4 public class VLCExample 
5 {
6
7     public static void main( String[] args )
8     {
9         boolean videoInput = false;
10         JVLC jvlc = new JVLC();
11
12         jvlc.playlist.add("file://" + System.getProperty( "user.dir" ) + "/a.avi", "a.avi");
13         jvlc.playlist.add("file://" + System.getProperty( "user.dir" ) + "/a.mp3", "a.mp3");
14         jvlc.playlist.play( -1 , null );
15         
16         while (! jvlc.isInputPlaying()) ;
17         
18         // testing vout functionalities
19
20         try {
21                 Thread.sleep(500);
22                 if (jvlc.hasVout()) videoInput = true;
23                 } catch (InterruptedException e) {
24                                 e.printStackTrace();
25                 }
26
27         if (videoInput) {
28                 System.out.print(jvlc.getVideoWidth());
29                 System.out.print("x");
30                 System.out.println(jvlc.getVideoHeight());
31         }
32         try 
33         {
34                 if (videoInput) {
35                         System.out.print("Fullscreen... ");             
36                         jvlc.setFullscreen(true);
37                         Thread.sleep(3000);
38                         System.out.println("real size.");
39                         jvlc.setFullscreen(false);
40                 System.out.print("Taking snapshot... ");
41                 jvlc.getSnapshot( System.getProperty( "user.dir" ) + "/snap.png");
42                 System.out.println("taken. (see " + System.getProperty( "user.dir" ) + "/snap.png )");
43                 }
44             System.out.print("Muting...");
45             jvlc.setMute(true);
46             Thread.sleep(3000);
47             System.out.println("unmuting.");
48             jvlc.setMute(false);
49             Thread.sleep(3000);
50             System.out.println("Volume is: " + jvlc.getVolume());
51             System.out.print("Setting volume to 150... ");
52             jvlc.setVolume(150);
53             System.out.println("done");
54             Thread.sleep(3000);
55             System.out.println("INPUT INFORMATION");
56             System.out.println("-----------------");
57             System.out.println("Total length   (ms) :\t" + jvlc.getInputLength());
58             System.out.println("Input time     (ms) :\t" + jvlc.getInputTime());
59             System.out.println("Input position [0-1]:\t" + jvlc.getInputPosition());
60             if (videoInput)
61                 System.out.println("Input FPS          :\t" + jvlc.getInputFPS());
62            
63             
64         }
65         
66         catch (Exception e) 
67         {
68                 System.out.println("Something was wrong. I die :(.");
69             jvlc.destroy();
70         }
71         
72         System.out.println("Everything fine ;)");
73         System.out.println("Playing next item");
74         jvlc.playlist.next();
75         
76         try {
77                 Thread.sleep(3000);
78         } catch (InterruptedException e) {
79                 e.printStackTrace();
80         }
81         jvlc.destroy();
82         return;
83     }
84 }
85