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