public abstract class DefaultMediaPlayer extends AbstractMediaPlayer implements MediaPlayer, EqualizerListener
Constructor and Description |
---|
DefaultMediaPlayer(LibVlc libvlc,
libvlc_instance_t instance)
Create a new media player.
|
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.
|
void |
equalizerChanged(Equalizer equalizer)
The state of the equalizer changed.
|
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.
|
String |
getAudioOutputDevice()
Get the identifier of the current audio output device, if available.
|
List<AudioDevice> |
getAudioOutputDevices()
Get the available audio devices for the media player audio output.
|
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.
|
String |
getCodecDescription(libvlc_track_type_t type,
int codec)
Get a description for a FourCC codec value.
|
float |
getContrast()
Get the current video contrast.
|
String |
getCropGeometry()
Get the current video crop geometry.
|
Equalizer |
getEqualizer()
Get the current audio equalizer.
|
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 media)
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.
|
boolean |
programScrambled()
Is the current program scrambled?
|
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 |
requestParseMediaWithOptions(libvlc_media_parse_flag_t... options)
Parse meta data from the current media, with options.
|
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.
|
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 |
setEqualizer(Equalizer equalizer)
Set the audio equalizer.
|
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... options)
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.
|
void |
setVideoTitleDisplay(libvlc_position_e position,
int timeout)
Set if, and how, the video title will be shown when playing media.
|
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.
|
public DefaultMediaPlayer(LibVlc libvlc, libvlc_instance_t instance)
libvlc
- native library interfaceinstance
- libvlc instancepublic void addMediaPlayerEventListener(MediaPlayerEventListener listener)
MediaPlayer
addMediaPlayerEventListener
in interface MediaPlayer
listener
- component to notifypublic void removeMediaPlayerEventListener(MediaPlayerEventListener listener)
MediaPlayer
removeMediaPlayerEventListener
in interface MediaPlayer
listener
- component to stop notifyingpublic void enableEvents(int eventMask)
MediaPlayer
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.
enableEvents
in interface MediaPlayer
eventMask
- bit mask of events to enablepublic void setStandardMediaOptions(String... options)
MediaPlayer
This will not affect any currently playing media item.
setStandardMediaOptions
in interface MediaPlayer
options
- options to apply to all subsequently played media itemspublic boolean playMedia(String mrl, String... mediaOptions)
MediaPlayer
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.
playMedia
in interface MediaPlayer
mrl
- media resource locatormediaOptions
- zero or more media item optionstrue
if the media item was created; false
otherwisepublic boolean prepareMedia(String mrl, String... mediaOptions)
MediaPlayer
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.
prepareMedia
in interface MediaPlayer
mrl
- media resource locatormediaOptions
- zero or more media item optionstrue
if the media item was created; false
otherwisepublic boolean startMedia(String mrl, String... mediaOptions)
MediaPlayer
This call will block until the media starts or errors.
startMedia
in interface MediaPlayer
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 errorpublic void parseMedia()
MediaPlayer
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.
parseMedia
in interface MediaPlayer
public void requestParseMedia()
MediaPlayer
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 is called then no event will be raised.
Invoking this method on a stream or DVB channel may cause a hang.
requestParseMedia
in interface MediaPlayer
public boolean requestParseMediaWithOptions(libvlc_media_parse_flag_t... options)
MediaPlayer
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 is called, or this function returns an error, then no event will be raised.
If no options are specified, then the file is parsed if it is a local file.
requestParseMediaWithOptions
in interface MediaPlayer
options
- optional optionstrue
if successful; false
on error (or e.g. requires LibVLC 3.0.0)public boolean isMediaParsed()
MediaPlayer
isMediaParsed
in interface MediaPlayer
true
if the current media has been parsed, otherwise false
public MediaMeta getMediaMeta()
MediaPlayer
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
MediaPlayer.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.
getMediaMeta
in interface MediaPlayer
public MediaMeta getMediaMeta(libvlc_media_t media)
MediaPlayer
See MediaPlayer.getMediaMeta()
, the same notes with regard to parsing hold here.
getMediaMeta
in interface MediaPlayer
media
- media instance, may be a sub-itempublic List<MediaMeta> getSubItemMediaMeta()
MediaPlayer
See MediaPlayer.getMediaMeta()
, the same notes with regard to parsing hold here.
getSubItemMediaMeta
in interface MediaPlayer
public void addMediaOptions(String... mediaOptions)
MediaPlayer
addMediaOptions
in interface MediaPlayer
mediaOptions
- media optionspublic void setRepeat(boolean repeat)
MediaPlayer
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.
setRepeat
in interface MediaPlayer
repeat
- true
to automatically replay the media, otherwise false
public boolean getRepeat()
MediaPlayer
getRepeat
in interface MediaPlayer
true
if the media will be automatically replayed, otherwise false
public void setPlaySubItems(boolean playSubItems)
MediaPlayer
setPlaySubItems
in interface MediaPlayer
playSubItems
- true
to automatically play sub-items, otherwise false
public int subItemCount()
MediaPlayer
subItemCount
in interface MediaPlayer
public int subItemIndex()
MediaPlayer
subItemIndex
in interface MediaPlayer
public List<String> subItems()
MediaPlayer
The MRL of each sub-item is returned in the list.
subItems
in interface MediaPlayer
null
if there is no current mediapublic List<libvlc_media_t> subItemsMedia()
MediaPlayer
The native media instance of each sub-item is returned in the list.
subItemsMedia
in interface MediaPlayer
null
if there is no current mediapublic MediaList subItemsMediaList()
MediaPlayer
MediaList
.subItemsMediaList
in interface MediaPlayer
null
if there is no current mediapublic boolean playNextSubItem(String... mediaOptions)
MediaPlayer
If any standard media options have been set via MediaPlayer.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.
playNextSubItem
in interface MediaPlayer
mediaOptions
- zero or more media options for the sub-itemtrue
if there is a sub-item, otherwise false
public boolean playSubItem(int index, String... mediaOptions)
MediaPlayer
If any standard media options have been set via MediaPlayer.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.
playSubItem
in interface MediaPlayer
index
- sub-item indexmediaOptions
- zero or more media options for the sub-itemtrue
if there is a sub-item, otherwise false
public boolean isPlayable()
MediaPlayer
isPlayable
in interface MediaPlayer
true
if the current media is playable, otherwise false
public boolean isPlaying()
MediaPlayer
isPlaying
in interface MediaPlayer
true
if the media player is playing, otherwise false
public boolean isSeekable()
MediaPlayer
isSeekable
in interface MediaPlayer
true
if the current media is seekable, otherwise false
public boolean canPause()
MediaPlayer
canPause
in interface MediaPlayer
true
if the current media can be paused, otherwise false
public boolean programScrambled()
MediaPlayer
Requires vlc 2.2.0 or later.
programScrambled
in interface MediaPlayer
true
if the current program is scrambled, otherwise false
public long getLength()
MediaPlayer
getLength
in interface MediaPlayer
public long getTime()
MediaPlayer
getTime
in interface MediaPlayer
public float getPosition()
MediaPlayer
getPosition
in interface MediaPlayer
public float getFps()
MediaPlayer
getFps
in interface MediaPlayer
public float getRate()
MediaPlayer
getRate
in interface MediaPlayer
public int getVideoOutputs()
MediaPlayer
getVideoOutputs
in interface MediaPlayer
public Dimension getVideoDimension()
MediaPlayer
The video dimensions are not available until after the video has started playing and a video output has been created.
getVideoDimension
in interface MediaPlayer
null
public MediaDetails getMediaDetails()
MediaPlayer
The details are available after the video has started playing, regardless of whether nor not a video output has been created.
getMediaDetails
in interface MediaPlayer
null
if the media meta data is not availablepublic String getAspectRatio()
MediaPlayer
getAspectRatio
in interface MediaPlayer
public float getScale()
MediaPlayer
getScale
in interface MediaPlayer
public String getCropGeometry()
MediaPlayer
getCropGeometry
in interface MediaPlayer
public libvlc_media_stats_t getMediaStatistics()
MediaPlayer
Statistics are only updated if the video is playing.
getMediaStatistics
in interface MediaPlayer
public libvlc_media_stats_t getMediaStatistics(libvlc_media_t media)
MediaPlayer
Statistics are only updated if the video is playing.
getMediaStatistics
in interface MediaPlayer
media
- media itempublic libvlc_state_t getMediaState()
MediaPlayer
getMediaState
in interface MediaPlayer
public libvlc_state_t getMediaPlayerState()
MediaPlayer
getMediaPlayerState
in interface MediaPlayer
public int getTitleCount()
MediaPlayer
getTitleCount
in interface MediaPlayer
public int getTitle()
MediaPlayer
getTitle
in interface MediaPlayer
public void setTitle(int title)
MediaPlayer
setTitle
in interface MediaPlayer
title
- title numberpublic int getVideoTrackCount()
MediaPlayer
getVideoTrackCount
in interface MediaPlayer
public int getVideoTrack()
MediaPlayer
getVideoTrack
in interface MediaPlayer
MediaPlayer.getVideoDescriptions()
public int setVideoTrack(int track)
MediaPlayer
The track identifier must be one of those returned by MediaPlayer.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
MediaPlayer.getVideoTrackCount()
-1. The MediaPlayer.getVideoDescriptions()
method should always
be used to ascertain the available track identifiers.
setVideoTrack
in interface MediaPlayer
track
- track identifierpublic int getAudioTrackCount()
MediaPlayer
getAudioTrackCount
in interface MediaPlayer
public int getAudioTrack()
MediaPlayer
getAudioTrack
in interface MediaPlayer
MediaPlayer.getAudioDescriptions()
public int setAudioTrack(int track)
MediaPlayer
The track identifier must be one of those returned by MediaPlayer.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
MediaPlayer.getAudioTrackCount()
-1. The MediaPlayer.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.
setAudioTrack
in interface MediaPlayer
track
- track identifierpublic void play()
MediaPlayer
If called when the play-back is paused, the play-back will resume from the current position.
play
in interface MediaPlayer
public boolean start()
MediaPlayer
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.
start
in interface MediaPlayer
true
if the media started playing, false
if the media failed to start because of an errorpublic void stop()
MediaPlayer
A subsequent play will play-back from the start.
stop
in interface MediaPlayer
public void setPause(boolean pause)
MediaPlayer
Requires vlc 1.1.1 or later.
setPause
in interface MediaPlayer
pause
- true to pause, false to play/resumepublic void pause()
MediaPlayer
If the play-back is currently paused it will begin playing.
pause
in interface MediaPlayer
public void nextFrame()
MediaPlayer
nextFrame
in interface MediaPlayer
public void skip(long delta)
MediaPlayer
To skip backwards specify a negative delta.
skip
in interface MediaPlayer
delta
- time period, in millisecondspublic void skipPosition(float delta)
MediaPlayer
To skip backwards specify a negative delta.
skipPosition
in interface MediaPlayer
delta
- amount to skippublic void setTime(long time)
MediaPlayer
If the requested time is less than zero, it is normalised to zero.
setTime
in interface MediaPlayer
time
- time since the beginning, in millisecondspublic void setPosition(float position)
MediaPlayer
If the requested position is less than zero, it is normalised to zero.
setPosition
in interface MediaPlayer
position
- position value, a percentage (e.g. 0.15 is 15%)public int setRate(float rate)
MediaPlayer
Some media protocols are not able to change the rate.
setRate
in interface MediaPlayer
rate
- rate, where 1.0 is normal speed, 0.5 is half speed, 2.0 is double speed and so onpublic void setAspectRatio(String aspectRatio)
MediaPlayer
setAspectRatio
in interface MediaPlayer
aspectRatio
- aspect ratio, e.g. "16:9", "4:3", "185:100" for 1:85.1 and so onpublic void setScale(float factor)
MediaPlayer
setScale
in interface MediaPlayer
factor
- scaling factor, or zero to scale the video the size of the containerpublic void setCropGeometry(String cropGeometry)
MediaPlayer
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
setCropGeometry
in interface MediaPlayer
cropGeometry
- formatted string describing the desired crop geometrypublic boolean setAudioOutput(String output)
MediaPlayer
The change will not be applied until the media player has been stopped and then played again.
The output name comes from MediaPlayerFactory.getAudioOutputs()
.
setAudioOutput
in interface MediaPlayer
output
- name of the desired audio outputtrue
if the output was successfully set, otherwise false
public void setAudioOutputDevice(String output, String outputDeviceId)
MediaPlayer
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()
.
setAudioOutputDevice
in interface MediaPlayer
output
- name of the desired audio outputoutputDeviceId
- id of the desired audio output devicepublic String getAudioOutputDevice()
MediaPlayer
To return a useful value, an audio output must be active (i.e. the media must be playing).
getAudioOutputDevice
in interface MediaPlayer
null
if not available (e.g. requires LibVLC 3.0.0)public List<AudioDevice> getAudioOutputDevices()
MediaPlayer
getAudioOutputDevices
in interface MediaPlayer
null
if not available (e.g. requires LibVLC 2.2.0)public void mute()
MediaPlayer
mute
in interface MediaPlayer
public void mute(boolean mute)
MediaPlayer
mute
in interface MediaPlayer
mute
- true
to mute the volume, false
to un-mute itpublic boolean isMute()
MediaPlayer
isMute
in interface MediaPlayer
true
if the volume is muted, false
if the volume is not mutedpublic int getVolume()
MediaPlayer
getVolume
in interface MediaPlayer
public void setVolume(int volume)
MediaPlayer
The volume is actually a percentage of full volume, setting a volume over 100 may cause audible distortion.
setVolume
in interface MediaPlayer
volume
- volume, a percentage of full volume in the range 0 to 200public int getAudioChannel()
MediaPlayer
libvlc_audio_output_channel_t
.
Warning this API is subject to change.getAudioChannel
in interface MediaPlayer
public void setAudioChannel(int channel)
MediaPlayer
libvlc_audio_output_channel_t
.
Warning this API is subject to change.setAudioChannel
in interface MediaPlayer
channel
- channelpublic long getAudioDelay()
MediaPlayer
getAudioDelay
in interface MediaPlayer
public void setAudioDelay(long delay)
MediaPlayer
The audio delay is set for the current item only and will be reset to zero each time the media changes.
setAudioDelay
in interface MediaPlayer
delay
- desired audio delay, in microsecondspublic int getChapterCount()
MediaPlayer
getChapterCount
in interface MediaPlayer
public int getChapter()
MediaPlayer
getChapter
in interface MediaPlayer
public void setChapter(int chapterNumber)
MediaPlayer
setChapter
in interface MediaPlayer
chapterNumber
- chapter number, where zero is the first chapterpublic void nextChapter()
MediaPlayer
If the play-back is already at the last chapter, this will have no effect.
nextChapter
in interface MediaPlayer
public void previousChapter()
MediaPlayer
If the play-back is already at the first chapter, this will have no effect.
previousChapter
in interface MediaPlayer
public void menuActivate()
MediaPlayer
menuActivate
in interface MediaPlayer
public void menuUp()
MediaPlayer
menuUp
in interface MediaPlayer
public void menuDown()
MediaPlayer
menuDown
in interface MediaPlayer
public void menuLeft()
MediaPlayer
menuLeft
in interface MediaPlayer
public void menuRight()
MediaPlayer
menuRight
in interface MediaPlayer
public int getSpuCount()
MediaPlayer
getSpuCount
in interface MediaPlayer
public int getSpu()
MediaPlayer
getSpu
in interface MediaPlayer
public int setSpu(int spu)
MediaPlayer
The track identifier must be one of those returned by MediaPlayer.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
MediaPlayer.getSpuCount()
-1. The MediaPlayer.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.
setSpu
in interface MediaPlayer
spu
- sub-title identifier, or -1 for nonepublic int cycleSpu()
MediaPlayer
This method is now deprecated and will be removed in the next major version of vlcj. The reason it is deprecated is that SPU tracks used to be identified and ordered by index, but this has changed now so that each SPU track has its own track identifier and the identifiers may not be contiguous.
Applications should instead use SPU track info to get the track identifiers and cycle the SPU tracks themselves.
cycleSpu
in interface MediaPlayer
public long getSpuDelay()
MediaPlayer
getSpuDelay
in interface MediaPlayer
public void setSpuDelay(long delay)
MediaPlayer
The sub-title delay is set for the current item only and will be reset to zero each time the media changes.
setSpuDelay
in interface MediaPlayer
delay
- desired sub-title delay, in microsecondspublic void setSubTitleFile(String subTitleFileName)
MediaPlayer
setSubTitleFile
in interface MediaPlayer
subTitleFileName
- name of the file containing the sub-titlespublic void setSubTitleFile(File subTitleFile)
MediaPlayer
setSubTitleFile
in interface MediaPlayer
subTitleFile
- file containing the sub-titlespublic int getTeletextPage()
MediaPlayer
getTeletextPage
in interface MediaPlayer
public void setTeletextPage(int pageNumber)
MediaPlayer
setTeletextPage
in interface MediaPlayer
pageNumber
- page numberpublic void toggleTeletext()
MediaPlayer
toggleTeletext
in interface MediaPlayer
public List<TrackDescription> getTitleDescriptions()
MediaPlayer
The media must be playing before this information is available.
getTitleDescriptions
in interface MediaPlayer
public List<TrackDescription> getVideoDescriptions()
MediaPlayer
The media must be playing before this information is available.
getVideoDescriptions
in interface MediaPlayer
public List<TrackDescription> getAudioDescriptions()
MediaPlayer
The media must be playing before this information is available.
getAudioDescriptions
in interface MediaPlayer
public List<TrackDescription> getSpuDescriptions()
MediaPlayer
The media must be playing before this information is available.
getSpuDescriptions
in interface MediaPlayer
public List<String> getChapterDescriptions(int title)
MediaPlayer
The media must be playing before this information is available.
getChapterDescriptions
in interface MediaPlayer
title
- title numbernull
if there is no such titlepublic List<String> getChapterDescriptions()
MediaPlayer
The media must be playing before this information is available.
getChapterDescriptions
in interface MediaPlayer
public List<List<String>> getAllChapterDescriptions()
MediaPlayer
The media must be playing before this information is available.
getAllChapterDescriptions
in interface MediaPlayer
public List<TrackInfo> getTrackInfo(TrackType... types)
MediaPlayer
The media (if local) should first be parsed, see MediaPlayer.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.
getTrackInfo
in interface MediaPlayer
types
- zero or more types of track to get, or all tracks if omittednull
if there is no current mediapublic List<TrackInfo> getTrackInfo(libvlc_media_t media, TrackType... types)
MediaPlayer
getTrackInfo
in interface MediaPlayer
media
- media itemtypes
- zero or more types of track to get, or all tracks if omittednull
if there is no current mediapublic String getCodecDescription(libvlc_track_type_t type, int codec)
MediaPlayer
Requires LibVLC 3.0.0 or later.
getCodecDescription
in interface MediaPlayer
type
- type of trackcodec
- codec valuepublic List<List<TrackInfo>> getSubItemTrackInfo(TrackType... types)
MediaPlayer
getSubItemTrackInfo
in interface MediaPlayer
types
- zero or more types of track to get, or all tracks if omittednull
if there is no current mediapublic void setSnapshotDirectory(String snapshotDirectoryName)
MediaPlayer
If the specified directory path does not yet exist, it will be created.
setSnapshotDirectory
in interface MediaPlayer
snapshotDirectoryName
- name of the directory to save snapshots topublic boolean saveSnapshot()
MediaPlayer
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 MediaPlayer.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.
saveSnapshot
in interface MediaPlayer
true
if the snapshot was saved, otherwise false
public boolean saveSnapshot(int width, int height)
MediaPlayer
The snapshot will be created in the directory set via MediaPlayer.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
MediaPlayer.saveSnapshot()
.
Taking a snapshot is an asynchronous function, the snapshot is not available until
after the MediaPlayerEventListener.snapshotTaken(MediaPlayer, String)
event
is received.
saveSnapshot
in interface MediaPlayer
width
- desired image widthheight
- desired image heighttrue
if the snapshot was saved, otherwise false
public boolean saveSnapshot(File file)
MediaPlayer
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.
saveSnapshot
in interface MediaPlayer
file
- file to contain the snapshottrue
if the snapshot was saved, otherwise false
public boolean saveSnapshot(File file, int width, int height)
MediaPlayer
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
MediaPlayer.saveSnapshot(File)
.
Taking a snapshot is an asynchronous function, the snapshot is not available until
after the MediaPlayerEventListener.snapshotTaken(MediaPlayer, String)
event
is received.
saveSnapshot
in interface MediaPlayer
file
- file to contain the snapshotwidth
- desired image widthheight
- desired image heighttrue
if the snapshot was saved, otherwise false
public BufferedImage getSnapshot()
MediaPlayer
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.
getSnapshot
in interface MediaPlayer
null
if a snapshot could not be takenpublic BufferedImage getSnapshot(int width, int height)
MediaPlayer
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
MediaPlayer.getSnapshot()
Taking a snapshot is an asynchronous function, the snapshot is not available until
after the MediaPlayerEventListener.snapshotTaken(MediaPlayer, String)
event
is received.
getSnapshot
in interface MediaPlayer
width
- desired image widthheight
- desired image heightnull
if a snapshot could not be takenpublic void enableLogo(boolean enable)
MediaPlayer
The logo will not be enabled if there is currently no video being played.
enableLogo
in interface MediaPlayer
enable
- true
to show the logo, false
to hide itpublic void setLogoOpacity(int opacity)
MediaPlayer
setLogoOpacity
in interface MediaPlayer
opacity
- opacity in the range 0 to 255 where 255 is fully opaquepublic void setLogoOpacity(float opacity)
MediaPlayer
setLogoOpacity
in interface MediaPlayer
opacity
- opacity percentage in the range 0.0 to 1.0 where 1.0 is fully opaquepublic void setLogoLocation(int x, int y)
MediaPlayer
setLogoLocation
in interface MediaPlayer
x
- x co-ordinate for the top left of the logoy
- y co-ordinate for the top left of the logopublic void setLogoPosition(libvlc_logo_position_e position)
MediaPlayer
setLogoPosition
in interface MediaPlayer
position
- positionpublic void setLogoFile(String logoFile)
MediaPlayer
setLogoFile
in interface MediaPlayer
logoFile
- logo file namepublic void setLogoImage(RenderedImage logoImage)
MediaPlayer
The image will first be written to a temporary file, before invoking
MediaPlayer.setLogoFile(String)
. This is not optimal, but creating a temporary file for the logo
in this way is unavoidable.
setLogoImage
in interface MediaPlayer
logoImage
- logo imagepublic void enableMarquee(boolean enable)
MediaPlayer
The marquee will not be enabled if there is currently no video being played.
enableMarquee
in interface MediaPlayer
enable
- true
to show the marquee, false
to hide itpublic void setMarqueeText(String text)
MediaPlayer
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
.setMarqueeText
in interface MediaPlayer
text
- textpublic void setMarqueeColour(Color colour)
MediaPlayer
setMarqueeColour
in interface MediaPlayer
colour
- colour, any alpha component will be masked offpublic void setMarqueeColour(int colour)
MediaPlayer
setMarqueeColour
in interface MediaPlayer
colour
- RGB colour valuepublic void setMarqueeOpacity(int opacity)
MediaPlayer
setMarqueeOpacity
in interface MediaPlayer
opacity
- opacity in the range 0 to 100 where 255 is fully opaquepublic void setMarqueeOpacity(float opacity)
MediaPlayer
setMarqueeOpacity
in interface MediaPlayer
opacity
- opacity percentage in the range 0.0 to 1.0 where 1.0 is fully opaquepublic void setMarqueeSize(int size)
MediaPlayer
setMarqueeSize
in interface MediaPlayer
size
- size, height of the marquee text in pixelspublic void setMarqueeTimeout(int timeout)
MediaPlayer
setMarqueeTimeout
in interface MediaPlayer
timeout
- timeout, in millisecondspublic void setMarqueeLocation(int x, int y)
MediaPlayer
setMarqueeLocation
in interface MediaPlayer
x
- x co-ordinate for the top left of the marqueey
- y co-ordinate for the top left of the marqueepublic void setMarqueePosition(libvlc_marquee_position_e position)
MediaPlayer
setMarqueePosition
in interface MediaPlayer
position
- positionpublic void setDeinterlace(DeinterlaceMode deinterlaceMode)
MediaPlayer
setDeinterlace
in interface MediaPlayer
deinterlaceMode
- mode, or null to disable the de-interlace filterpublic void setAdjustVideo(boolean adjustVideo)
MediaPlayer
The video adjustment controls must be enabled after the video has started playing.
Requires vlc 1.1.1 or later.
setAdjustVideo
in interface MediaPlayer
adjustVideo
- true if the video adjustments are enabled, otherwise falsepublic boolean isAdjustVideo()
MediaPlayer
Requires vlc 1.1.1 or later.
isAdjustVideo
in interface MediaPlayer
public float getContrast()
MediaPlayer
Requires vlc 1.1.1 or later.
getContrast
in interface MediaPlayer
public void setContrast(float contrast)
MediaPlayer
Video adjustments must be enabled for this to have any effect. Requires vlc 1.1.1 or later.
setContrast
in interface MediaPlayer
contrast
- contrast value, in the range from 0.0 to 2.0public float getBrightness()
MediaPlayer
Requires vlc 1.1.1 or later.
getBrightness
in interface MediaPlayer
public void setBrightness(float brightness)
MediaPlayer
Video adjustments must be enabled for this to have any effect.
Requires vlc 1.1.1 or later.
setBrightness
in interface MediaPlayer
brightness
- brightness value, in the range from 0.0 to 2.0public int getHue()
MediaPlayer
Requires vlc 1.1.1 or later.
getHue
in interface MediaPlayer
public void setHue(int hue)
MediaPlayer
Video adjustments must be enabled for this to have any effect.
Requires vlc 1.1.1 or later.
setHue
in interface MediaPlayer
hue
- hue value, in the range from 0 to 360public float getSaturation()
MediaPlayer
Requires vlc 1.1.1 or later.
getSaturation
in interface MediaPlayer
public void setSaturation(float saturation)
MediaPlayer
Video adjustments must be enabled for this to have any effect.
Requires vlc 1.1.1 or later.
setSaturation
in interface MediaPlayer
saturation
- saturation value, in the range from 0.0 to 3.0public float getGamma()
MediaPlayer
Requires vlc 1.1.1 or later.
getGamma
in interface MediaPlayer
public void setGamma(float gamma)
MediaPlayer
Video adjustments must be enabled for this to have any effect.
Requires vlc 1.1.1 or later.
setGamma
in interface MediaPlayer
gamma
- gamma, in the range from 0.01 to 10.0public void setVideoTitleDisplay(libvlc_position_e position, int timeout)
MediaPlayer
setVideoTitleDisplay
in interface MediaPlayer
position
- position, libvlc_position_e.disable
to prevent the title from appearingtimeout
- time to display the title in milliseconds (ignored when the title is disabled)public Equalizer getEqualizer()
MediaPlayer
Requires vlc 2.2.0 or later.
getEqualizer
in interface MediaPlayer
null
if there is no active equalizerpublic void setEqualizer(Equalizer equalizer)
MediaPlayer
Requires vlc 2.2.0 or later.
setEqualizer
in interface MediaPlayer
equalizer
- equalizer, or null
to disable the audio equalizerpublic String mrl()
MediaPlayer
The native media instance may be an automatically/scripted added sub-item.
mrl
in interface MediaPlayer
null
if there is no current mediapublic String mrl(libvlc_media_t mediaInstance)
MediaPlayer
The native media instance may be an automatically/scripted added sub-item.
mrl
in interface MediaPlayer
mediaInstance
- native media instancepublic Object userData()
MediaPlayer
userData
in interface MediaPlayer
public void userData(Object userData)
MediaPlayer
userData
in interface MediaPlayer
userData
- user datapublic final void release()
MediaPlayer
release
in interface MediaPlayer
public final libvlc_media_player_t mediaPlayerInstance()
MediaPlayer
This is exposed on the interface as an implementation side-effect, ordinary applications are not expected to use this.
mediaPlayerInstance
in interface MediaPlayer
public final void equalizerChanged(Equalizer equalizer)
EqualizerListener
equalizerChanged
in interface EqualizerListener
equalizer
- the equalizer that changedCopyright © 2009–2015 Caprica Software Limited. All rights reserved.