Caprica Software

vlcj 4.x Tutorial

Marquee

Building on previous tutorials, we will now use the marquee to overlay some text on the video.


Let's Get Started

You should now already have a basic template for how to create a vlcj application, so this tutorial will no longer duplicate all of the code each time - instead we'll just show the new code fragments.


Create a Marquee

You create a marquee by using a builder:

Marquee marquee = Marquee.marquee()
.text("vlcj tutorial")
.size(40)
.colour(Color.WHITE)
.timeout(3000)
.position(MarqueePosition.BOTTOM_RIGHT)
.opacity(0.8f)
.enable();

Using the Marquee

For historical reasons there are two ways to use the marquee, whichever way you choose is essentially a matter of preference.

marquee.apply(mediaPlayerComponent.mediaPlayer());

Alternatively:

mediaPlayerComponent.mediaPlayer().marquee().set(marquee);

Marquee API

You do not have to use the builder, you can invoke the individual API methods directly:

mediaPlayerComponent.mediaPlayer().marquee().setText("vlcj tutorial");
mediaPlayerComponent.mediaPlayer().marquee().setSize(40);
mediaPlayerComponent.mediaPlayer().marquee().setColour(Color.WHITE);
mediaPlayerComponent.mMediaPlayer().marquee().setTimeout(3000);
mediaPlayerComponent.mMediaPlayer().marquee().setPosition(libvlc_marquee_position_e.bottom);
mediaPlayerComponent.mediaPlayer().marquee().setOpacity(0.8f);
mediaPlayerComponent.mediaPlayer().marquee().enable(true);

Disabling the Marquee

Using the builder approach, create a marquee without invoking enable() and then apply or set it.

Using the API directly:

mediaPlayerComponent.mediaPlayer().marquee().enable(false);

When To Use Marquee

A marquee can be set at any time, even before media is playing.

You no longer need to explicitly enable the native marq video filter module, with VLC 3.x this is all handled automatically by LibVLC.