When using VLC options/arguments to initialise the factory, generally any options that enable/disable modules (e.g.
video/audio filters) must be set via the factory instance and not when invoking
MediaApi.play(String, String...)
. However, the module-specific
options may be able to be passed as media options and be effective via that play call.
The factory will attempt to automatically discover the location of the required LibVLC native library, so it should
just work by default (at least for the most common/likely environment configurations). If you have other requirements
for the native library discovery mechanism, you can pass in your own implementation of NativeDiscovery
when
you create the factory.
You should explicitly release()
the factory when your application terminates to properly clean up native
resources.
The factory also provides access to the native libvlc Logger and other resources such as the list of audio outputs, and the list of available audio and video filters.
You must make sure you keep a hard reference to the components created by this factory to prevent them from going out of scope and being garbage-collected. If you allow one of these components to go out of scope, then unpredictable behaviour will occur (such as events no longer seeming to fire) even though the video playback may continue (since that happens via native code). You will also likely suffer fatal JVM crashes.
It is always a better strategy to reuse media player instances, rather than repeatedly creating and destroying them.
-
Constructor Summary
ConstructorDescriptionCreate a new media player factory with default native discovery and no initialisation options.MediaPlayerFactory
(String... libvlcArgs) Create a new media player factory with default native discovery.MediaPlayerFactory
(Collection<String> libvlcArgs) Create a new media player factory with default native discovery.MediaPlayerFactory
(NativeDiscovery discovery, String... libvlcArgs) Create a new media player factory.MediaPlayerFactory
(NativeDiscovery discovery, Collection<String> libvlcArgs) Create a new media player factory. -
Method Summary
Modifier and TypeMethodDescriptionfinal ApplicationApi
final AudioApi
audio()
final DialogsApi
dialogs()
final EqualizerApi
final MediaApi
media()
final MediaDiscovererApi
final MediaPlayerApi
final NativeDiscoveryStrategy
Get the native discovery strategy instance that discovered the native library.final String
Get the discovered native library path.final void
release()
Release all native resources associated with this factory.final RendererApi
final void
Submit a task for asynchronous execution.final VideoSurfaceApi
-
Constructor Details
-
MediaPlayerFactory
Create a new media player factory.- Parameters:
discovery
- native discovery used to locate the native LibVLC library, may benull
libvlcArgs
- array of options/arguments to pass to LibVLC for initialisation of the native library- Throws:
NativeLibraryMappingException
- if one or more of the declared method bindings inLibVlc
could not be found in the native library that was loaded
-
MediaPlayerFactory
Create a new media player factory with default native discovery.If you do not want to use native discovery, use the
MediaPlayerFactory(NativeDiscovery, String...)
constructor instead, passingnull
.- Parameters:
libvlcArgs
- array of options/arguments to pass to LibVLC for initialisation of the native library
-
MediaPlayerFactory
Create a new media player factory.If you do not want to use native discovery, pass
null
for thediscovery
parameter.- Parameters:
discovery
- native discovery used to locate the native LibVLC library, may benull
libvlcArgs
- collection of options/arguments to pass to LibVLC for initialisation of the native library
-
MediaPlayerFactory
Create a new media player factory with default native discovery.If you do not want to use native discovery, use the
MediaPlayerFactory(NativeDiscovery, Collection)
constructor instead, passingnull
.- Parameters:
libvlcArgs
- collection of options/arguments to pass to LibVLC for initialisation of the native library
-
MediaPlayerFactory
public MediaPlayerFactory()Create a new media player factory with default native discovery and no initialisation options.
-
-
Method Details
-
application
-
audio
-
dialogs
-
mediaDiscoverers
-
equalizer
-
mediaPlayers
-
media
-
renderers
-
videoSurfaces
-
submit
Submit a task for asynchronous execution.This is useful in particular for event handling code as native events are generated on a native event callback thread and it is not allowed to call back into LibVLC from this callback thread. If you do, either the call will be ineffective, strange behaviour will happen, or a fatal JVM crash may occur.
To mitigate this, those tasks can be offloaded from the native thread, serialised and executed using this method.
- Parameters:
r
- task to execute
-
release
public final void release()Release all native resources associated with this factory.The factory must not be used again after it has been released.
-
nativeDiscoveryStrategy
Get the native discovery strategy instance that discovered the native library.Used only for diagnostic purposes.
- Returns:
- strategy instance
-
nativeLibraryPath
Get the discovered native library path.Used only for diagnostic purposes.
- Returns:
- native library path
-