I can play .mpg format video with the Java media framework. But I can not play all format of video. When I want to play .AVI format video, the video is play but the sound is not come. How to play other format such as FLV, mp4, avi?
public class MediaPanel extends JPanel
{
public Player mediaPlayer;
public Component video;
public Component controls;
public MediaPanel(URL mediaURl)
{
setLayout(new BorderLayout());
Manager.setHint(Manager.LIGHTWEIGHT_RENDERER, true);
try
{
//Player
// this. mediaPlayer.stop();
//this.mediaPlayer.close();
mediaPlayer=Manager.createRealizedPlayer(mediaURl);
//Component
video=mediaPlayer.getVisualComponent();
//Component
controls=mediaPlayer.getControlPanelComponent();
if(video!=null)
add(video,BorderLayout.CENTER);
if(controls!=null)
add(controls,BorderLayout.SOUTH);
mediaPlayer.start();
}
catch(NoPlayerException noPlayerException)
{
System.err.println("No media");
}
catch(CannotRealizeException cannotRealizeException)
{
System.err.println("Could not");
}
catch(IOException iOException)
{
System.err.println("Error");
}
}}