Dialogs
Some API methods may cause a native dialog to be requested by VLC.
For example if there is an error playing media, or if VLC needs to request credentials from the user if playing a protected stream.
By default, native dialog requests are not enabled.
Enabling Dialogs
Native dialogs are enabled via the MediaPlayerFactory
:
After creating the factory, this example uses that factory to create a
Dialogs
component. This dialogs component is a bridge between the Java
application and the dialogs requested by the native library.
Once a dialogs component has been created, it is enabled via the dialogs API on the factory.
Now, any request to display a native dialog will get routed via this dialogs component.
Adding Dialog Handlers
This example shows how to add a handler for an error dialog request:
This example shows how to add a handler for a login credentials dialog request, note here the use of the dismiss method to close/cancel the dialog:
This is just an example to show the concept, obviously a real application would provide something more robust.
Specifically for the login dialog, it is necessary to specify a keystore when creating the media player factory, for example:
Without this keystore setting the application will most likely hang when requesting the dialog.
General Notes
Any number of dialog handlers can be added, or implementations for multiple dialogs can be provided in a single handler.
As these examples have demonstrated, there is no requirement to display an actual dialog box to handle these dialog requests.