Class MediaPlayer

java.lang.Object
uk.co.caprica.vlcj.player.base.MediaPlayer
Direct Known Subclasses:
EmbeddedMediaPlayer

public class MediaPlayer extends Object
Base media player implementation.

This can be used for those media players that do not require a video surface embedded into a user interface, for example audio-only players, or less likely media players that will use a native window created by LibVLC.

  • Constructor Details

    • MediaPlayer

      public MediaPlayer(uk.co.caprica.vlcj.binding.internal.libvlc_instance_t instance)
      Create a new media player.
      Parameters:
      instance - libvlc instance
    • MediaPlayer

      public MediaPlayer(uk.co.caprica.vlcj.binding.internal.libvlc_instance_t instance, uk.co.caprica.vlcj.binding.internal.libvlc_media_player_t mediaPlayerInstance)
      Create a new media player.

      This constructor for internal use only.

      Parameters:
      instance - libvlc instance
      mediaPlayerInstance - native media player instance
  • Method Details

    • audio

      public final AudioApi audio()
    • chapters

      public final ChapterApi chapters()
    • controls

      public final ControlsApi controls()
    • events

      public final EventApi events()
    • logo

      public final LogoApi logo()
    • marquee

      public final MarqueeApi marquee()
    • media

      public final MediaApi media()
    • role

      public final RoleApi role()
    • snapshots

      public final SnapshotApi snapshots()
    • status

      public final StatusApi status()
    • subitems

      public final SubitemApi subitems()
    • subpictures

      public final SubpictureApi subpictures()
    • teletext

      public final TeletextApi teletext()
    • titles

      public final TitleApi titles()
    • video

      public final VideoApi video()
    • setRenderer

      public final boolean setRenderer(RendererItem rendererItem)
      Set an alternate media renderer.

      If the supplied renderer item is not null this component will invoke RendererItem.hold().

      If a renderer was previously set, RendererItemRendererItem.release() will be invoked.

      A client application therefore need not, although it may, concern itself with hold/release.

      If the new renderer could not be set it will be properly released (i.e. the hold acquired in this method will not be kept).

      Parameters:
      rendererItem - media renderer, or null to render as normal
      Returns:
      true if successful; false on error
    • userData

      public final Object userData()
      Get the user data associated with the media player.
      Returns:
      user data
    • userData

      public final void userData(Object userData)
      Set user data to associate with the media player.
      Parameters:
      userData - user data
    • submit

      public final void submit(Runnable r)
      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 the media player, freeing all associated (including native) resources.
    • mediaPlayerInstance

      public final uk.co.caprica.vlcj.binding.internal.libvlc_media_player_t mediaPlayerInstance()
      Provide access to the native media player instance.

      This is exposed on the interface as an implementation side-effect, ordinary applications are not expected to use this.

      Returns:
      media player instance