]> git.sesse.net Git - vlc/blob - bindings/java/VLCExample.java
setSize native function signature fixed
[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                         Thread.sleep(2000);
54                 System.out.println("Resizing to 300x300");
55                 jvlc.video.setSize(300, 300);
56                                 
57                 }
58             System.out.print("Muting...");
59             jvlc.audio.setMute(true);
60             Thread.sleep(3000);
61             System.out.println("unmuting.");
62             jvlc.audio.setMute(false);
63             Thread.sleep(3000);
64             System.out.println("Volume is: " + jvlc.audio.getVolume());
65             System.out.print("Setting volume to 150... ");
66             jvlc.audio.setVolume(150);
67             System.out.println("done");
68             Thread.sleep(3000);
69             System.out.println("INPUT INFORMATION");
70             System.out.println("-----------------");
71             System.out.println("Total length   (ms) :\t" + jvlc.input.getLength());
72             System.out.println("Input time     (ms) :\t" + jvlc.input.getTime());
73             System.out.println("Input position [0-1]:\t" + jvlc.input.getPosition());
74             if (videoInput)
75                 System.out.println("Input FPS          :\t" + jvlc.input.getFPS());
76            
77             
78         }
79         
80         catch (Exception e) 
81         {
82                 System.out.println("Something was wrong. I die :(.");
83             jvlc.destroy();
84         }
85         
86         System.out.println("Everything fine ;)");
87         System.out.println("Playing next item");
88         try {
89                 jvlc.playlist.next();
90         } catch (VLCException e) {
91                 e.printStackTrace();
92         }
93         
94         try {
95                 Thread.sleep(3000);
96         } catch (InterruptedException e) {
97                 e.printStackTrace();
98         }
99         jvlc.destroy();
100         return;
101     }
102 }
103