some options for libvlc String[] libvlcArgs = {...add options here...}; // Create a factory instance (once), you can keep a reference to this MediaPlayerFactory mediaPlayerFactory = new MediaPlayerFactory(libvlcArgs); // Create a full-screen strategy FullScreenStrategy fullScreenStrategy = new DefaultFullScreenStrategy(mainFrame); // Create a media player instance EmbeddedMediaPlayer mediaPlayer = mediaPlayerFactory.newEmbeddedMediaPlayer(fullScreenStrategy); // Do some interesting things with the media player, like setting a video surface... ... // Release the media player mediaPlayer.release(); // Release the factory factory.release(); You
must make sure you keep a hard reference to the media player (and possibly other) objects created by this factory. If you allow a media player object to go out of scope, then unpredictable behaviour will occur (such as events no longer seeming to fire) even though the video playback continues (since that happens via native code). You may also likely suffer fatal JVM crashes.
It is always a better strategy to reuse media player instances, rather than repeatedly creating and destroying instances.