Hi Filippo!
I have setup an example based on yours (MultipleVideosSample.java) that you can use to test what I stated in my original message.
filename is now an array of video file names that are located in the folder indicated by the filepath variable (/home/user/ in the example). Just change the video names for those that you have and the location of them in the filepath variable and run the example. When you click on the name of a video in the list, that video is supposed to switch the mute state. If you select the mute all checkbox, all videos are supposed to be muted and when de-selected, all videos should have audio again. Play with it and you see what I mean.
OS: Ubuntu 8.10 Intrepid
VLC: (0.9.0 - 0.9.4)
IDE: EasyEclipse 1.2.2.2
Here is the code of the example:
Code: Select all
import java.awt.*;
import java.awt.event.*;
import javax.swing.JPanel;
import org.videolan.jvlc.*;
/*****************************************************************************
* MultipleVideosSample.java: VLC Java Bindings
*****************************************************************************
* Copyright (C) 1998-2008 the VideoLAN team
*
* Authors: Filippo Carone <filippo@carone.org>
*
*
* $Id $
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
public class MultipleVideosSample implements ItemListener
{
public void itemStateChanged(ItemEvent arg0) {
try{
if(arg0.getSource() instanceof Checkbox)
{
Checkbox chk = (Checkbox)(arg0.getSource());
muteAllVideos( chk.getState());
}
else
{
int inx = lisVideo.getSelectedIndex();
System.out.println( ((lisAud[inx].getMute())?"Un-":"")+"Muting: "+filename[inx]+ " was : "+lisAud[inx].getMute());
lisAud[inx].setMute(!lisAud[inx].getMute());
}
}catch(Exception ee)
{ System.out.println("Error al asignar nuevo estado de audio ..."); }
}
private void muteAllVideos(boolean es)
{ System.out.println(" Setting mute to : "+es);
for (int i = 0; i < videosNumber; i++)
{
System.out.println( ((es)?"":"Un-")+"Muting: "+filename[i]+ " was : "+lisAud[i].getMute());
lisAud[i].setMute(es);
}
}
private static int videosNumber = 6;
private static String filename[] = {"video1.avi","video2.avi","video3.avi","video4.avi","video5.avi","video6.flv"};
private static String filepath = "/home/user/";
Frame frame = new java.awt.Frame();
JPanel jvcc = new JPanel();
JPanel pansel = new JPanel();
Checkbox muteAll = new Checkbox("Mute all");
List lisVideo = new List();
Audio lisAud[] = new Audio[videosNumber];
Scrollbar selVol = new Scrollbar(0,100,0,1,1);
Canvas[] videoCanvasesArray = new Canvas[videosNumber];
JVLC[] jvlcArray = new JVLC[videosNumber];
public MultipleVideosSample()
{
frame.setBounds(0, 0, 600, 750);
muteAll.addItemListener(this);
lisVideo.addItemListener(this);
frame.add("Center", jvcc);
frame.add("South",pansel);
pansel.add(lisVideo);
pansel.add(selVol);
pansel.add(muteAll);
for (int i = 0; i < videosNumber; i++)
{
Canvas jvlcCanvas = new Canvas();
videoCanvasesArray[i] = jvlcCanvas;
jvlcCanvas.setSize(200, 200);
jvlcCanvas.setBackground(new Color(0x0));
jvcc.add(jvlcCanvas);
lisVideo.add(filename[i]);
}
frame.addWindowListener(new WindowAdapter()
{
@Override
public void windowClosing(WindowEvent ev)
{
System.exit(0);
}
});
frame.setVisible(true);
for (int i = 0; i < videosNumber; i++)
{
JVLC jvlc = new JVLC();
jvlcArray[i] = jvlc;
lisAud[i] = new Audio(jvlc);
jvlc.setVideoOutput(videoCanvasesArray[i]);
}
for (int i = 0; i < videosNumber; i++)
{
jvlcArray[i].play(filepath+filename[i]);
try{
Thread.sleep(500);
} catch(Exception ee){System.out.println("Error al dormir thread ");}
}
}
public static void main(String[] args) throws Exception
{
MultipleVideosSample smp = new MultipleVideosSample();
}
}