--- 1 frame.setContentPane(mediaPlayerComponent); frame.setSize(1050, 600); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); mediaPlayerComponent.getMediaPlayer().playMedia(mrl); // <--- 2 An example of a sub-class to tailor behaviours and override event handlers:
mediaPlayerComponent = new EmbeddedMediaPlayerComponent() { protected String[] onGetMediaPlayerFactoryArgs() { return new String[] {"--no-video-title-show"}; } protected FullScreenStrategy onGetFullScreenStrategy() { return new XFullScreenStrategy(frame); } public void videoOutputAvailable(MediaPlayer mediaPlayer, boolean videoOutput) { } public void error(MediaPlayer mediaPlayer) { } public void finished(MediaPlayer mediaPlayer) { } };
When the media player component is no longer needed, it should be released by invoking the {@link #release()} method.
Since the media player factory associated by this component may be created by this component itself or may be shared with some other media player resources it is the responsibility of the application to also release the media player factory at the appropriate time.
It is always a better strategy to reuse media player components, rather than repeatedly creating and destroying instances.