public class AudioMediaPlayerComponent extends MediaPlayerEventAdapter
Most implementation details, like creating a factory, are encapsulated.
The default implementation will work out-of-the-box, but there are various template methods available to sub-classes to tailor the behaviour of the component.
This class implements the most the most common use-case for an audio player and is intended to
enable a developer to get quickly started with the vlcj framework. More advanced applications are
free to directly use the MediaPlayerFactory
, if required, as has always been the case.
This component also adds implements the various media player listener interfaces, consequently an implementation sub-class can simply override those listener methods to handle events.
Applications can get a handle to the underlying media player object by invoking
getMediaPlayer()
.
To use, simply create an instance of this class.
In this minimal example, only two lines of code are required to create an audio player and play media:
mediaPlayerComponent = new AudioMediaPlayerComponent(); // <--- 1 mediaPlayerComponent.getMediaPlayer().playMedia(mrl); // <--- 2This is not quite as useful as the
EmbeddedMediaPlayerComponent
as audio players are
generally quite simple to create anyway.
An audio player may still have a user interface, but it will not have an associated video surface.
When the media player component is no longer needed, it should be released by invoking the
release()
method.
Since the media player factory associated by this component may be created by this component itself or may be shared with some other media player resources it is the responsibility of the application to also release the media player factory at the appropriate time.
It is always a better strategy to reuse media player components, rather than repeatedly creating and destroying instances.
Constructor and Description |
---|
AudioMediaPlayerComponent()
Construct a media player component.
|
Modifier and Type | Method and Description |
---|---|
MediaPlayer |
getMediaPlayer()
Get the embedded media player reference.
|
MediaPlayerFactory |
getMediaPlayerFactory()
Get the media player factory reference.
|
void |
release()
Release the media player component and the associated native media player resources.
|
void |
release(boolean releaseFactory)
Release the media player component and the associated media player factory.
|
backward, buffering, elementaryStreamAdded, elementaryStreamDeleted, elementaryStreamSelected, endOfSubItems, error, finished, forward, lengthChanged, mediaChanged, mediaDurationChanged, mediaFreed, mediaMetaChanged, mediaParsedChanged, mediaStateChanged, mediaSubItemAdded, newMedia, opening, pausableChanged, paused, playing, positionChanged, scrambledChanged, seekableChanged, snapshotTaken, stopped, subItemFinished, subItemPlayed, timeChanged, titleChanged, videoOutput
public AudioMediaPlayerComponent()
public final MediaPlayerFactory getMediaPlayerFactory()
public final MediaPlayer getMediaPlayer()
An application uses this handle to control the media player, add listeners and so on.
public final void release()
The associated media player factory will not be released, the client application is responsible for releasing the factory at the appropriate time.
public final void release(boolean releaseFactory)
Optionally release the media player factory.
This method invokes release()
, then depending on the value of the releaseFactory
parameter the associated factory will also be released.
releaseFactory
- true
if the factory should also be released; false
if it should notCopyright © 2009–2014 Caprica Software Limited. All rights reserved.