public interface MediaPlayer
A media player provides the following functions:
The basic life-cycle is:
// Set some options for libvlc String[] libvlcArgs = {...add options here...}; // Create a factory MediaPlayerFactory mediaPlayerFactory = new MediaPlayerFactory(libvlcArgs); // Create a full-screen strategy FullScreenStrategy fullScreenStrategy = new DefaultFullScreenStrategy(mainFrame); // Create a media player instance (in this example an embedded media player) EmbeddedMediaPlayer mediaPlayer = mediaPlayerFactory.newEmbeddedMediaPlayer(fullScreenStrategy); // Set standard options as needed to be applied to all subsequently played media items String[] standardMediaOptions = {"video-filter=logo", "logo-file=vlcj-logo.png", "logo-opacity=25"}; mediaPlayer.setStandardMediaOptions(standardMediaOptions); // Add a component to be notified of player events mediaPlayer.addMediaPlayerEventListener(new MediaPlayerEventAdapter() {...add implementation here...}); // Create and set a new component to display the rendered video (not shown: add the Canvas to a Frame) Canvas canvas = new Canvas(); CanvasVideoSurface videoSurface = mediaPlayerFactory.newVideoSurface(canvas); mediaPlayer.setVideoSurface(videoSurface); // Play a particular item, with options if necessary String mediaPath = "/path/to/some/movie.mpg"; String[] mediaOptions = {...add options here...}; mediaPlayer.playMedia(mediaPath, mediaOptions); // Do some interesting things in the application ... // Cleanly dispose of the media player instance and any associated native resources mediaPlayer.release(); // Cleanly dispose of the media player factory and any associated native resources mediaPlayerFactory.release();With regard to overlaying logos there are three approaches.
The first way is to specify standard options for the media player - this will set the logo for any subsequently played media item, for example:
String[] standardMediaOptions = {"video-filter=logo", "logo-file=vlcj-logo.png", "logo-opacity=25"}; mediaPlayer.setStandardMediaOptions(standardMediaOptions);The second way is to specify options when playing the media item, for example:
String[] mediaOptions = {"video-filter=logo", "logo-file=vlcj-logo.png", "logo-opacity=25"}; mediaPlayer.playMedia(mediaPath, mediaOptions);The final way is to use the methods of this class to set various logo properties, for example:
mediaPlayer.setLogoFile("vlcj-logo.png"); mediaPlayer.setLogoOpacity(25); mediaPlayer.setLogoLocation(10, 10); mediaPlayer.enableLogo(true);For this latter method, it is not possible to enable the logo until after the video has started playing. There is also a noticeable stutter in video play-back when enabling the logo filter in this way.
With regard to overlaying marquees, again there are three approaches (similar to those for logos).
In this instance only the final way showing the usage of the API is used, for example:
mediaPlayer.setMarqueeText("VLCJ is quite good"); mediaPlayer.setMarqueeSize(60); mediaPlayer.setMarqueeOpacity(70); mediaPlayer.setMarqueeColour(Color.green); mediaPlayer.setMarqueeTimeout(3000); mediaPlayer.setMarqueeLocation(300, 400); mediaPlayer.enableMarquee(true);With regard to video adjustment controls, after the video has started playing:
mediaPlayer.setAdjustVideo(true); mediaPlayer.setGamma(0.9f); mediaPlayer.setHue(10);Some media when played may cause one or more media sub-items to created. These sub-items subsequently need to be played. The media player can be set to automatically play these sub-items via
setPlaySubItems(boolean)
, otherwise playNextSubItem(String...)
can be
invoked in response to a MediaPlayerEventListener.finished(MediaPlayer)
event.
It is always a better strategy to reuse media player instances, rather than repeatedly creating and destroying instances.
Note that media player implementations will guarantee that native media player events are delivered in a single-threaded sequential manner.
EmbeddedMediaPlayerComponent
Modifier and Type | Method and Description |
---|---|
void |
addMediaOptions(String... mediaOptions)
Add options to the current media.
|
void |
addMediaPlayerEventListener(MediaPlayerEventListener listener)
Add a component to be notified of media player events.
|
boolean |
canPause()
Can the current media be paused?
|
int |
cycleSpu()
Select the next sub-title track (or disable sub-titles).
|
void |
enableEvents(int eventMask)
Restrict the set of media player events that generate event notifications to listeners.
|
void |
enableLogo(boolean enable)
Enable/disable the logo.
|
void |
enableMarquee(boolean enable)
Enable/disable the marquee.
|
List<List<String>> |
getAllChapterDescriptions()
Get all of the chapter descriptions for all available titles.
|
String |
getAspectRatio()
Get the video aspect ratio.
|
int |
getAudioChannel()
Get the current audio channel.
|
long |
getAudioDelay()
Get the audio delay.
|
List<TrackDescription> |
getAudioDescriptions()
Get the audio track descriptions.
|
AudioOutputDeviceType |
getAudioOutputDeviceType()
Get the audio output device type.
|
int |
getAudioTrack()
Get the current audio track.
|
int |
getAudioTrackCount()
Get the number of available audio tracks.
|
float |
getBrightness()
Get the current video brightness.
|
int |
getChapter()
Get the current chapter.
|
int |
getChapterCount()
Get the chapter count.
|
List<String> |
getChapterDescriptions()
Get the chapter descriptions for the current title.
|
List<String> |
getChapterDescriptions(int title)
Get the chapter descriptions for a title.
|
float |
getContrast()
Get the current video contrast.
|
String |
getCropGeometry()
Get the current video crop geometry.
|
float |
getFps()
Get the current play-back frames-per-second.
|
float |
getGamma()
Get the current video gamma.
|
int |
getHue()
Get the current video hue.
|
long |
getLength()
Get the length of the current media item.
|
MediaDetails |
getMediaDetails()
Get the media details.
|
MediaMeta |
getMediaMeta()
Get local meta data for the current media.
|
MediaMeta |
getMediaMeta(libvlc_media_t mediaInstance)
Get local meta data for a media instance.
|
libvlc_state_t |
getMediaPlayerState()
Get the media player current state.
|
libvlc_state_t |
getMediaState()
Get the current media state.
|
libvlc_media_stats_t |
getMediaStatistics()
Get the current media statistics.
|
libvlc_media_stats_t |
getMediaStatistics(libvlc_media_t media)
Get the current media statistics for a media item (e.g.
|
float |
getPosition()
Get the current play-back position.
|
float |
getRate()
Get the current video play rate.
|
boolean |
getRepeat()
Test whether or not the media player will automatically repeat playing the media when it has
finished playing.
|
float |
getSaturation()
Get the current video saturation.
|
float |
getScale()
Get the current video scale (zoom).
|
BufferedImage |
getSnapshot()
Get a snapshot of the currently playing video.
|
BufferedImage |
getSnapshot(int width,
int height)
Get a snapshot of the currently playing video.
|
int |
getSpu()
Get the current sub-title track.
|
int |
getSpuCount()
Get the number of sub-pictures/sub-titles.
|
long |
getSpuDelay()
Get the sub-title delay.
|
List<TrackDescription> |
getSpuDescriptions()
Get the sub-title track descriptions.
|
List<MediaMeta> |
getSubItemMediaMeta()
Get local meta data for all of the current media sub-items (if there are any).
|
List<List<TrackInfo>> |
getSubItemTrackInfo(TrackType... types)
Get the track (i.e.
|
int |
getTeletextPage()
Get the current teletext page.
|
long |
getTime()
Get the current play-back time.
|
int |
getTitle()
Get the current title.
|
int |
getTitleCount()
Get the number of titles.
|
List<TrackDescription> |
getTitleDescriptions()
Get the title descriptions.
|
List<TrackInfo> |
getTrackInfo(libvlc_media_t media,
TrackType... types)
Get track (i.e.
|
List<TrackInfo> |
getTrackInfo(TrackType... types)
Get the track (i.e.
|
List<TrackDescription> |
getVideoDescriptions()
Get the video (i.e.
|
Dimension |
getVideoDimension()
Get the video size.
|
int |
getVideoOutputs()
Get the number of video outputs for the media player.
|
int |
getVideoTrack()
Get the current video track.
|
int |
getVideoTrackCount()
Get the number of available video tracks.
|
int |
getVolume()
Get the current volume.
|
boolean |
isAdjustVideo()
Test whether or not the video adjustments are enabled.
|
boolean |
isMediaParsed()
Test whether or not the current media has been parsed.
|
boolean |
isMute()
Test whether or not the volume is currently muted.
|
boolean |
isPlayable()
Is the current media playable?
|
boolean |
isPlaying()
Is the media player playing?
|
boolean |
isSeekable()
Is the current media seekable?
|
libvlc_media_player_t |
mediaPlayerInstance()
Provide access to the native media player instance.
|
void |
menuActivate()
Activate a DVD menu.
|
void |
menuDown()
Navigate down a DVD menu.
|
void |
menuLeft()
Navigate left a DVD menu.
|
void |
menuRight()
Navigate right a DVD menu.
|
void |
menuUp()
Navigate up a DVD menu.
|
String |
mrl()
Get the media resource locator for the current media instance.
|
String |
mrl(libvlc_media_t mediaInstance)
Get the media resource locator for a media instance.
|
void |
mute()
Toggle volume mute.
|
void |
mute(boolean mute)
Mute or un-mute the volume.
|
void |
nextChapter()
Jump to the next chapter.
|
void |
nextFrame()
Advance one frame.
|
void |
parseMedia()
Parse local meta data from the current media.
|
void |
pause()
Pause play-back.
|
void |
play()
Begin play-back.
|
boolean |
playMedia(String mrl,
String... mediaOptions)
Play a new media item, with options.
|
boolean |
playNextSubItem(String... mediaOptions)
Play the next sub-item (if there is one).
|
boolean |
playSubItem(int index,
String... mediaOptions)
Play a particular sub-item (if there is one).
|
boolean |
prepareMedia(String mrl,
String... mediaOptions)
Prepare a new media item for play-back, but do not begin playing.
|
void |
previousChapter()
Jump to the previous chapter.
|
void |
release()
Release the media player, freeing all associated (including native) resources.
|
void |
removeMediaPlayerEventListener(MediaPlayerEventListener listener)
Remove a component that was previously interested in notifications of media player events.
|
void |
requestParseMedia()
Parse local meta data from the current media.
|
boolean |
saveSnapshot()
Save a snapshot of the currently playing video.
|
boolean |
saveSnapshot(File file)
Save a snapshot of the currently playing video.
|
boolean |
saveSnapshot(File file,
int width,
int height)
Save a snapshot of the currently playing video.
|
boolean |
saveSnapshot(int width,
int height)
Save a snapshot of the currently playing video.
|
void |
setAdjustVideo(boolean adjustVideo)
Enable/disable the video adjustments.
|
void |
setAspectRatio(String aspectRatio)
Set the video aspect ratio
|
void |
setAudioChannel(int channel)
Set the audio channel.
|
void |
setAudioDelay(long delay)
Set the audio delay.
|
boolean |
setAudioOutput(String output)
Set the desired audio output.
|
void |
setAudioOutputDevice(String output,
String outputDeviceId)
Set the desired audio output device.
|
void |
setAudioOutputDeviceType(AudioOutputDeviceType deviceType)
Set the audio output device type.
|
int |
setAudioTrack(int track)
Set a new audio track to play.
|
void |
setBrightness(float brightness)
Set the video brightness.
|
void |
setChapter(int chapterNumber)
Set the chapter.
|
void |
setContrast(float contrast)
Set the video contrast.
|
void |
setCropGeometry(String cropGeometry)
Set the crop geometry.
|
void |
setDeinterlace(DeinterlaceMode deinterlaceMode)
Set the de-interlace filter to use.
|
void |
setGamma(float gamma)
Set the video gamma.
|
void |
setHue(int hue)
Set the video hue.
|
void |
setLogoFile(String logoFile)
Set the logo file.
|
void |
setLogoImage(RenderedImage logoImage)
Set the logo image.
|
void |
setLogoLocation(int x,
int y)
Set the logo location.
|
void |
setLogoOpacity(float opacity)
Set the logo opacity.
|
void |
setLogoOpacity(int opacity)
Set the logo opacity.
|
void |
setLogoPosition(libvlc_logo_position_e position)
Set the logo position.
|
void |
setMarqueeColour(Color colour)
Set the marquee colour.
|
void |
setMarqueeColour(int colour)
Set the marquee colour.
|
void |
setMarqueeLocation(int x,
int y)
Set the marquee location.
|
void |
setMarqueeOpacity(float opacity)
Set the marquee opacity.
|
void |
setMarqueeOpacity(int opacity)
Set the marquee opacity.
|
void |
setMarqueePosition(libvlc_marquee_position_e position)
Set the marquee position.
|
void |
setMarqueeSize(int size)
Set the marquee size.
|
void |
setMarqueeText(String text)
Set the marquee text.
|
void |
setMarqueeTimeout(int timeout)
Set the marquee timeout.
|
void |
setPause(boolean pause)
Pause/resume.
|
void |
setPlaySubItems(boolean playSubItems)
Set whether or not the media player should automatically play media sub- items.
|
void |
setPosition(float position)
Jump to a specific position.
|
int |
setRate(float rate)
Set the video play rate.
|
void |
setRepeat(boolean repeat)
Set whether or not the media player should automatically repeat playing the media when it has
finished playing.
|
void |
setSaturation(float saturation)
Set the video saturation.
|
void |
setScale(float factor)
Set the video scaling factor.
|
void |
setSnapshotDirectory(String snapshotDirectoryName)
Set the directory into which snapshots of the video are saved.
|
int |
setSpu(int spu)
Set the current sub-title track.
|
void |
setSpuDelay(long delay)
Set the sub-title delay.
|
void |
setStandardMediaOptions(String... mediaOptions)
Set standard media options for all media items subsequently played.
|
void |
setSubTitleFile(File subTitleFile)
Set the sub-title file to use.
|
void |
setSubTitleFile(String subTitleFileName)
Set the sub-title file to use.
|
void |
setTeletextPage(int pageNumber)
Set the new teletext page to retrieve.
|
void |
setTime(long time)
Jump to a specific moment.
|
void |
setTitle(int title)
Set a new title to play.
|
int |
setVideoTrack(int track)
Set a new video track to play.
|
void |
setVolume(int volume)
Set the volume.
|
void |
skip(long delta)
Skip forward or backward by a period of time.
|
void |
skipPosition(float delta)
Skip forward or backward by a change in position.
|
boolean |
start()
Begin play-back and wait for the media to start playing or for an error to occur.
|
boolean |
startMedia(String mrl,
String... mediaOptions)
Play a new media item, with options, and wait for it to start playing or error.
|
void |
stop()
Stop play-back.
|
int |
subItemCount()
Get the number of sub-items (if any).
|
int |
subItemIndex()
Get the index of the current sub-item.
|
List<String> |
subItems()
Get the list of sub-items (if any).
|
List<libvlc_media_t> |
subItemsMedia()
Get the list of sub-item media instances (if any).
|
MediaList |
subItemsMediaList()
Get the sub-items as a
MediaList . |
void |
toggleTeletext()
Toggle teletext status.
|
Object |
userData()
Get the user data associated with the media player.
|
void |
userData(Object userData)
Set user data to associate with the media player.
|
void addMediaPlayerEventListener(MediaPlayerEventListener listener)
listener
- component to notifyvoid removeMediaPlayerEventListener(MediaPlayerEventListener listener)
listener
- component to stop notifyingvoid enableEvents(int eventMask)
If a set of events is not explicitly enabled, then it is expected that all events be enabled.
See MediaPlayerEventType
.
This setting applies to all registered event listeners - it is not (currently) possible to set a different event mask for each listener.
eventMask
- bit mask of events to enablevoid setStandardMediaOptions(String... mediaOptions)
This will not affect any currently playing media item.
mediaOptions
- options to apply to all subsequently played media itemsboolean playMedia(String mrl, String... mediaOptions)
The new media will begin play-back asynchronously. This means that some media player functions will likely not work if you invoke them immediately after invoking this method - you will in some circumstances need to wait for an appropriate event to be fired before some API functions will have an effect.
When playing files, depending on the run-time Operating System it may be necessary to pass a URL here (beginning with "file://") rather than a local file path. This should actually not be required.
mrl
- media resource locatormediaOptions
- zero or more media item optionstrue
if the media item was created; false
otherwiseboolean prepareMedia(String mrl, String... mediaOptions)
When playing files, depending on the run-time Operating System it may be necessary to pass a URL here (beginning with "file://") rather than a local file path.
mrl
- media resource locatormediaOptions
- zero or more media item optionstrue
if the media item was created; false
otherwiseboolean startMedia(String mrl, String... mediaOptions)
This call will block until the media starts or errors.
mrl
- media resource locatormediaOptions
- zero or more media item optionstrue
if the media started playing, false
if the media failed to start because of an errorvoid parseMedia()
This method is synchronous.
Parsing media may cause an HTTP request to be made to search for cover- art.
Invoking this method on a stream or DVB channel may cause a hang.
void requestParseMedia()
This method is asynchronous and a media player event will be raised when the parsed status changes.
Parsing media may cause an HTTP request to be made to search for cover- art.
If the media has already been parsed when this function calls then no event will be raised.
Invoking this method on a stream or DVB channel may cause a hang.
boolean isMediaParsed()
true
if the current media has been parsed, otherwise false
MediaMeta getMediaMeta()
Some media types require that the media be parsed before accessing meta data - it is the
responsibility of the client application to parse the media if required, see
parseMedia()
.
Note that requesting meta data may cause one or more HTTP connections to be made to external web-sites to attempt download of album art.
MediaMeta getMediaMeta(libvlc_media_t mediaInstance)
See getMediaMeta()
, the same notes with regard to parsing hold here.
mediaInstance
- media instance, may be a sub-itemList<MediaMeta> getSubItemMediaMeta()
See getMediaMeta()
, the same notes with regard to parsing hold here.
void addMediaOptions(String... mediaOptions)
mediaOptions
- media optionsvoid setRepeat(boolean repeat)
There is no guarantee of seamless play-back when using this method - see instead
MediaListPlayer
.
If the media has sub-items, then it is the sub-items that are repeated.
repeat
- true
to automatically replay the media, otherwise false
boolean getRepeat()
true
if the media will be automatically replayed, otherwise false
void setPlaySubItems(boolean playSubItems)
playSubItems
- true
to automatically play sub-items, otherwise false
int subItemCount()
int subItemIndex()
List<String> subItems()
The MRL of each sub-item is returned in the list.
null
if there is no current mediaList<libvlc_media_t> subItemsMedia()
The native media instance of each sub-item is returned in the list.
null
if there is no current mediaMediaList subItemsMediaList()
MediaList
.null
if there is no current mediaboolean playNextSubItem(String... mediaOptions)
If any standard media options have been set via setStandardMediaOptions(String...)
then those options will be applied to the sub-item.
If the media player has been set to automatically repeat, then the sub- items will be repeated once the last one has been played.
mediaOptions
- zero or more media options for the sub-itemtrue
if there is a sub-item, otherwise false
boolean playSubItem(int index, String... mediaOptions)
If any standard media options have been set via setStandardMediaOptions(String...)
then those options will be applied to the sub-item.
If the media player has been set to automatically repeat, then the sub- items will be repeated once the last one has been played, or if the requested sub-item index exceeds the currently available sub-items.
index
- sub-item indexmediaOptions
- zero or more media options for the sub-itemtrue
if there is a sub-item, otherwise false
boolean isPlayable()
true
if the current media is playable, otherwise false
boolean isPlaying()
true
if the media player is playing, otherwise false
boolean isSeekable()
true
if the current media is seekable, otherwise false
boolean canPause()
true
if the current media can be paused, otherwise false
long getLength()
long getTime()
float getPosition()
float getFps()
float getRate()
int getVideoOutputs()
Dimension getVideoDimension()
The video dimensions are not available until after the video has started playing and a video output has been created.
null
MediaDetails getMediaDetails()
The details are available after the video has started playing, regardless of whether nor not a video output has been created.
null
if the media meta data is not availableString getAspectRatio()
float getScale()
String getCropGeometry()
libvlc_media_stats_t getMediaStatistics()
Statistics are only updated if the video is playing.
libvlc_media_stats_t getMediaStatistics(libvlc_media_t media)
Statistics are only updated if the video is playing.
media
- media itemlibvlc_state_t getMediaState()
libvlc_state_t getMediaPlayerState()
int getTitleCount()
int getTitle()
void setTitle(int title)
title
- title numberint getVideoTrackCount()
int getVideoTrack()
getVideoDescriptions()
int setVideoTrack(int track)
The track identifier must be one of those returned by getVideoDescriptions()
.
Video can be disabled by passing here the identifier of the track with a description of "Disable".
There is no guarantee that the available track identifiers go in sequence from zero up to
getVideoTrackCount()
-1. The getVideoDescriptions()
method should always
be used to ascertain the available track identifiers.
track
- track identifierint getAudioTrackCount()
int getAudioTrack()
getAudioDescriptions()
int setAudioTrack(int track)
The track identifier must be one of those returned by getAudioDescriptions()
.
Audio can be disabled by passing here the identifier of the track with a description of "Disable".
There is no guarantee that the available track identifiers go in sequence from zero up to
getAudioTrackCount()
-1. The getAudioDescriptions()
method should always
be used to ascertain the available track identifiers.
The implementation of the corresponding native method in libvlc is bugged before vlc 2.0.5, therefore vlc 2.0.5 or later is required for correct behaviour when using this method.
track
- track identifiervoid play()
If called when the play-back is paused, the play-back will resume from the current position.
boolean start()
If called when the play-back is paused, the play-back will resume from the current position.
This call will block until the media starts or errors.
true
if the media started playing, false
if the media failed to start because of an errorvoid stop()
A subsequent play will play-back from the start.
void setPause(boolean pause)
Requires vlc 1.1.1 or later.
pause
- true to pause, false to play/resumevoid pause()
If the play-back is currently paused it will begin playing.
void nextFrame()
void skip(long delta)
To skip backwards specify a negative delta.
delta
- time period, in millisecondsvoid skipPosition(float delta)
To skip backwards specify a negative delta.
delta
- void setTime(long time)
If the requested time is less than zero, it is normalised to zero.
time
- time since the beginning, in millisecondsvoid setPosition(float position)
If the requested position is less than zero, it is normalised to zero.
position
- position value, a percentage (e.g. 0.15 is 15%)int setRate(float rate)
Some media protocols are not able to change the rate.
rate
- rate, where 1.0 is normal speed, 0.5 is half speed, 2.0 is double speed and so onvoid setAspectRatio(String aspectRatio)
aspectRatio
- aspect ratiovoid setScale(float factor)
factor
- scaling factor, or zero to scale the video the size of the containervoid setCropGeometry(String cropGeometry)
The format for the crop geometry is one of:
mediaPlayer.setCropGeometry("4:3"); // W:H mediaPlayer.setCropGeometry("719x575+0+0"); // WxH+L+T mediaPlayer.setCropGeometry("6+10+6+10"); // L+T+R+B
cropGeometry
- formatted string describing the desired crop geometryboolean setAudioOutput(String output)
The change will not be applied until the media player has been stopped and then played again.
The output name comes from MediaPlayerFactory.getAudioOutputs()
.
output
- name of the desired audio outputtrue
if the output was successfully set, otherwise false
void setAudioOutputDevice(String output, String outputDeviceId)
The change will not be applied until the media player has been stopped and then played again.
The output name comes from MediaPlayerFactory.getAudioOutputs()
.
The device id comes from the AudioDevice.getDeviceId()
returned by
MediaPlayerFactory.getAudioOutputs()
.
output
- name of the desired audio outputoutputDeviceId
- id of the desired audio output devicevoid setAudioOutputDeviceType(AudioOutputDeviceType deviceType)
deviceType
- device typeAudioOutputDeviceType getAudioOutputDeviceType()
void mute()
void mute(boolean mute)
mute
- true
to mute the volume, false
to un-mute itboolean isMute()
true
if the volume is muted, false
if the volume is not mutedint getVolume()
void setVolume(int volume)
The volume is actually a percentage of full volume, setting a volume over 100 may cause audible distortion.
volume
- volume, a percentage of full volume in the range 0 to 200int getAudioChannel()
libvlc_audio_output_channel_t
.
Warning this API is subject to change.void setAudioChannel(int channel)
libvlc_audio_output_channel_t
.
Warning this API is subject to change.channel
- channellong getAudioDelay()
void setAudioDelay(long delay)
The audio delay is set for the current item only and will be reset to zero each time the media changes.
delay
- desired audio delay, in microsecondsint getChapterCount()
int getChapter()
void setChapter(int chapterNumber)
chapterNumber
- chapter number, where zero is the first chaptervoid nextChapter()
If the play-back is already at the last chapter, this will have no effect.
void previousChapter()
If the play-back is already at the first chapter, this will have no effect.
void menuActivate()
void menuUp()
void menuDown()
void menuLeft()
void menuRight()
int getSpuCount()
int getSpu()
int setSpu(int spu)
The track identifier must be one of those returned by getSpuDescriptions()
.
Subtitles can be disabled by passing here the identifier of the track with a description of "Disable".
There is no guarantee that the available subtitle identifiers go in sequence from zero up to
getSpuCount()
-1. The getSpuDescriptions()
method should always
be used to ascertain the available subtitle identifiers.
The implementation of the corresponding native method in libvlc is bugged before vlc 2.0.6, therefore vlc 2.0.6 or later is required for correct behaviour when using this method.
spu
- sub-title identifier, or -1 for noneint cycleSpu()
long getSpuDelay()
void setSpuDelay(long delay)
The sub-title delay is set for the current item only and will be reset to zero each time the media changes.
delay
- desired sub-title delay, in microsecondsvoid setSubTitleFile(String subTitleFileName)
subTitleFileName
- name of the file containing the sub-titlesvoid setSubTitleFile(File subTitleFile)
subTitleFile
- file containing the sub-titlesint getTeletextPage()
void setTeletextPage(int pageNumber)
pageNumber
- page numbervoid toggleTeletext()
List<TrackDescription> getTitleDescriptions()
The media must be playing before this information is available.
List<TrackDescription> getVideoDescriptions()
The media must be playing before this information is available.
List<TrackDescription> getAudioDescriptions()
The media must be playing before this information is available.
List<TrackDescription> getSpuDescriptions()
The media must be playing before this information is available.
List<String> getChapterDescriptions(int title)
The media must be playing before this information is available.
title
- title numbernull
if there is no such titleList<String> getChapterDescriptions()
The media must be playing before this information is available.
List<List<String>> getAllChapterDescriptions()
The media must be playing before this information is available.
List<TrackInfo> getTrackInfo(TrackType... types)
The media (if local) should first be parsed, see parseMedia()
, or be already
playing.
In the case of DVD media (for example ".iso" files) and streams the media must be played and video output must be available before valid track information becomes available, and even then it is not always available immediately (or it is only partially available) so polling may be required.
If you invoke this method "too soon", you may only receive partial track information.
types
- zero or more types of track to get, or all tracks if omittednull
if there is no current mediaList<TrackInfo> getTrackInfo(libvlc_media_t media, TrackType... types)
media
- media itemtypes
- zero or more types of track to get, or all tracks if omittednull
if there is no current mediaList<List<TrackInfo>> getSubItemTrackInfo(TrackType... types)
types
- zero or more types of track to get, or all tracks if omittednull
if there is no current mediavoid setSnapshotDirectory(String snapshotDirectoryName)
If the specified directory path does not yet exist, it will be created.
snapshotDirectoryName
- name of the directory to save snapshots toboolean saveSnapshot()
The size of the image will be that produced by the libvlc native snapshot function, i.e. the size of the media itself.
The snapshot will be created in the directory set via setSnapshotDirectory(String)
,
unless that directory has not been set in which case the snapshot will be created in the
user's home directory, obtained via the "user.home" system property.
The snapshot will be assigned a filename based on the current time.
The size of the image will be that produced by the libvlc native snapshot function.
Taking a snapshot is an asynchronous function, the snapshot is not available until
after the MediaPlayerEventListener.snapshotTaken(MediaPlayer, String)
event
is received.
true
if the snapshot was saved, otherwise false
boolean saveSnapshot(int width, int height)
The snapshot will be created in the directory set via setSnapshotDirectory(String)
,
unless that directory has not been set in which case the snapshot will be created in the
user's home directory, obtained via the "user.home" system property.
The snapshot will be assigned a filename based on the current time.
If one of width or height is zero the original image aspect ratio will be preserved.
If both width and height are zero, the original image size will be used, see
saveSnapshot()
.
Taking a snapshot is an asynchronous function, the snapshot is not available until
after the MediaPlayerEventListener.snapshotTaken(MediaPlayer, String)
event
is received.
width
- desired image widthheight
- desired image heighttrue
if the snapshot was saved, otherwise false
boolean saveSnapshot(File file)
The size of the image will be that produced by the libvlc native snapshot function, i.e. the size of the media itself.
Any missing directory path will be created if it does not exist.
Taking a snapshot is an asynchronous function, the snapshot is not available until
after the MediaPlayerEventListener.snapshotTaken(MediaPlayer, String)
event
is received.
file
- file to contain the snapshottrue
if the snapshot was saved, otherwise false
boolean saveSnapshot(File file, int width, int height)
Any missing directory path will be created if it does not exist.
If one of width or height is zero the original image aspect ratio will be preserved.
If both width and height are zero, the original image size will be used, see
saveSnapshot(File)
.
Taking a snapshot is an asynchronous function, the snapshot is not available until
after the MediaPlayerEventListener.snapshotTaken(MediaPlayer, String)
event
is received.
file
- file to contain the snapshotwidth
- desired image widthheight
- desired image heighttrue
if the snapshot was saved, otherwise false
BufferedImage getSnapshot()
The size of the image will be that produced by the libvlc native snapshot function, i.e. the size of the media itself.
This implementation uses the native libvlc method to save a snapshot of the currently playing video. This snapshot is saved to a temporary file and then the resultant image is loaded from the file.
Taking a snapshot is an asynchronous function, the snapshot is not available until
after the MediaPlayerEventListener.snapshotTaken(MediaPlayer, String)
event
is received.
null
if a snapshot could not be takenBufferedImage getSnapshot(int width, int height)
This implementation uses the native libvlc method to save a snapshot of the currently playing video. This snapshot is saved to a temporary file and then the resultant image is loaded from the file.
If one of width or height is zero the original image aspect ratio will be preserved.
If both width and height are zero, the original image size will be used, see
getSnapshot()
Taking a snapshot is an asynchronous function, the snapshot is not available until
after the MediaPlayerEventListener.snapshotTaken(MediaPlayer, String)
event
is received.
width
- desired image widthheight
- desired image heightnull
if a snapshot could not be takenvoid enableLogo(boolean enable)
The logo will not be enabled if there is currently no video being played.
enable
- true
to show the logo, false
to hide itvoid setLogoOpacity(int opacity)
opacity
- opacity in the range 0 to 255 where 255 is fully opaquevoid setLogoOpacity(float opacity)
opacity
- opacity percentage in the range 0.0 to 1.0 where 1.0 is fully opaquevoid setLogoLocation(int x, int y)
x
- x co-ordinate for the top left of the logoy
- y co-ordinate for the top left of the logovoid setLogoPosition(libvlc_logo_position_e position)
position
- positionvoid setLogoFile(String logoFile)
logoFile
- logo file namevoid setLogoImage(RenderedImage logoImage)
The image will first be written to a temporary file, before invoking
setLogoFile(String)
. This is not optimal, but creating a temporary file for the logo
in this way is unavoidable.
logoImage
- logo imagevoid enableMarquee(boolean enable)
The marquee will not be enabled if there is currently no video being played.
enable
- true
to show the marquee, false
to hide itvoid setMarqueeText(String text)
Format variables are available:
Time related: %Y = year %d = day %H = hour %M = minute %S = secondMeta data related:
$a = artist $b = album $c = copyright $d = description $e = encoded by $g = genre $l = language $n = track num $p = now playing $r = rating $s = subtitles language $t = title $u = url $A = date $B = audio bitrate (in kb/s) $C = chapter $D = duration $F = full name with path $I = title $L = time left $N = name $O = audio language $P = position (in %) $R = rate $S = audio sample rate (in kHz) $T = time $U = publisher $V = volume $_ = new lineSee
http://wiki.videolan.org/index.php?title=Documentation:Modules/marq
.text
- textvoid setMarqueeColour(Color colour)
colour
- colour, any alpha component will be masked offvoid setMarqueeColour(int colour)
colour
- RGB colour valuevoid setMarqueeOpacity(int opacity)
opacity
- opacity in the range 0 to 100 where 255 is fully opaquevoid setMarqueeOpacity(float opacity)
opacity
- opacity percentage in the range 0.0 to 1.0 where 1.0 is fully opaquevoid setMarqueeSize(int size)
size
- size, height of the marquee text in pixelsvoid setMarqueeTimeout(int timeout)
timeout
- timeout, in millisecondsvoid setMarqueeLocation(int x, int y)
x
- x co-ordinate for the top left of the marqueey
- y co-ordinate for the top left of the marqueevoid setMarqueePosition(libvlc_marquee_position_e position)
position
- positionvoid setDeinterlace(DeinterlaceMode deinterlaceMode)
deinterlaceMode
- mode, or null to disable the de-interlace filtervoid setAdjustVideo(boolean adjustVideo)
The video adjustment controls must be enabled after the video has started playing.
Requires vlc 1.1.1 or later.
adjustVideo
- true if the video adjustments are enabled, otherwise falseboolean isAdjustVideo()
Requires vlc 1.1.1 or later.
float getContrast()
Requires vlc 1.1.1 or later.
void setContrast(float contrast)
Video adjustments must be enabled for this to have any effect. Requires vlc 1.1.1 or later.
contrast
- contrast value, in the range from 0.0 to 2.0float getBrightness()
Requires vlc 1.1.1 or later.
void setBrightness(float brightness)
Video adjustments must be enabled for this to have any effect.
Requires vlc 1.1.1 or later.
brightness
- brightness value, in the range from 0.0 to 2.0int getHue()
Requires vlc 1.1.1 or later.
void setHue(int hue)
Video adjustments must be enabled for this to have any effect.
Requires vlc 1.1.1 or later.
hue
- hue value, in the range from 0 to 360float getSaturation()
Requires vlc 1.1.1 or later.
void setSaturation(float saturation)
Video adjustments must be enabled for this to have any effect.
Requires vlc 1.1.1 or later.
saturation
- saturation value, in the range from 0.0 to 3.0float getGamma()
Requires vlc 1.1.1 or later.
void setGamma(float gamma)
Video adjustments must be enabled for this to have any effect.
Requires vlc 1.1.1 or later.
gamma
- gamma, in the range from 0.01 to 10.0String mrl()
The native media instance may be an automatically/scripted added sub-item.
null
if there is no current mediaString mrl(libvlc_media_t mediaInstance)
The native media instance may be an automatically/scripted added sub-item.
mediaInstance
- native media instanceObject userData()
void userData(Object userData)
userData
- user datavoid release()
libvlc_media_player_t mediaPlayerInstance()
This is exposed on the interface as an implementation side-effect, ordinary applications are not expected to use this.
Copyright © 2009-2013 Caprica Software Limited. All Rights Reserved.