Adding Component over Video(Visual component)
Hi All
I'm new to JMF.My goal is to add a Swing component on top of video.In this test exaple i'm trying to add a Button on top of video.When i run the test i can c only video playing and no trace of button in the foreground.Can anyone help me with this.Here's the code
publicclass JMFSample
{
// launch the application
publicstaticvoid main( String args[] )
{
URL mediaURL =null;
try
{
mediaURL =new URL("demo.mpg");
}// end try
catch ( MalformedURLException malformedURLException )
{
System.err.println("Could not create URL for the file" );
}// end catch
try
{
Manager.setHint( Manager.LIGHTWEIGHT_RENDERER,true );
Player mediaPlayer = nager.createRealizedPlayer(mediaURL);
// add components
Component visualComp = MediaPlayer.getVisualComponent();
JFrame myframe =new JFrame();
LayeredPane layers =new JLayeredPane(){
public Dimension getPreferredSize(){
returnnew Dimension (300,300);
}
public Dimension getMinimumSize(){
returnnew Dimension (300,300);
}
};
visualComp.setBounds (0, 0,
visualComp.getPreferredSize().width,
visualComp.getPreferredSize().height);
layers.add (visualComp, JLayeredPane.DEFAULT_LAYER);
Button myOverlay =new Button("overlayText");
layers.add(myOverlay, JLayeredPane.POPUP_LAYER);
myframe.add(layers);
myframe.pack();
myframe.setVisible(true);
}
catch ( NoPlayerException noPlayerException )
{
System.err.println("No media player found" );
}// end catch
catch ( CannotRealizeException cannotRealizeException )
{
System.err.println("Could not realize media player" );
}// end catch
catch ( IOException iOException )
{
System.err.println("Error reading from the source" );
}
}// end main
}// end class MediaTes

