]> git.sesse.net Git - vlc/blob - bindings/java/samples/client/src/main/java/MultipleVideosSample.java
Add some locking.
[vlc] / bindings / java / samples / client / src / main / java / MultipleVideosSample.java
1 import java.awt.Canvas;
2 import java.awt.Color;
3 import java.awt.Frame;
4 import java.awt.event.WindowAdapter;
5 import java.awt.event.WindowEvent;
6
7 import javax.swing.JPanel;
8
9 import org.videolan.jvlc.JVLC;
10
11 /*****************************************************************************
12  * MultipleVideosSample.java: VLC Java Bindings
13  *****************************************************************************
14  * Copyright (C) 1998-2008 the VideoLAN team
15  *
16  * Authors: Filippo Carone <filippo@carone.org>
17  *
18  *
19  * $Id $
20  *
21  * This program is free software; you can redistribute it and/or modify
22  * it under the terms of the GNU General Public License as published by
23  * the Free Software Foundation; either version 2 of the License, or
24  * (at your option) any later version.
25  *
26  * This program is distributed in the hope that it will be useful,
27  * but WITHOUT ANY WARRANTY; without even the implied warranty of
28  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
29  * GNU General Public License for more details.
30  *
31  * You should have received a copy of the GNU General Public License
32  * along with this program; if not, write to the Free Software
33  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
34  *****************************************************************************/
35
36 public class MultipleVideosSample
37 {
38
39     private static int videosNumber = 6;
40     private static String filename ="/home/carone/a.avi";
41     
42     public static void main(String[] args) throws Exception
43     {
44         Frame frame = new java.awt.Frame();
45         frame.setBounds(0, 0, 600, 700);
46         JPanel jvcc = new JPanel();
47         Canvas[] videoCanvasesArray = new Canvas[videosNumber];
48         frame.add(jvcc);
49         
50         if (args.length > 0)
51         {
52             filename = args[0];
53         }
54         
55         for (int i = 0; i < videosNumber; i++)
56         {
57             Canvas jvlcCanvas = new Canvas();
58             videoCanvasesArray[i] = jvlcCanvas;
59             jvlcCanvas.setSize(200, 200);
60             jvlcCanvas.setBackground(new Color(0x0));
61             jvcc.add(jvlcCanvas);
62         }
63         
64         frame.addWindowListener(new WindowAdapter()
65         {
66
67             @Override
68             public void windowClosing(WindowEvent ev)
69             {
70                 System.exit(0);
71             }
72         });
73         
74         frame.setVisible(true);
75         JVLC[] jvlcArray = new JVLC[videosNumber];
76         for (int i = 0; i < videosNumber; i++)
77         {
78             JVLC jvlc = new JVLC();
79             jvlcArray[i] = jvlc;
80             jvlc.setVideoOutput(videoCanvasesArray[i]);
81         }
82         
83         for (int i = 0; i < videosNumber; i++)
84         {
85             jvlcArray[i].play(filename);
86             jvlcArray[i].setVideoOutput(videoCanvasesArray[i]);
87             Thread.sleep(500);
88         }
89     }
90     
91 }