org.gstreamer.elements
public class PlayBin2 extends Pipeline
Playbin2 provides a stand-alone everything-in-one abstraction for an audio and/or video player.
At this stage, playbin2 is considered UNSTABLE. The API provided in the signals and properties may yet change in the near future. When playbin2 is stable, it will probably replace playbin
It can handle both audio and video files and features
Playbin2 is a Pipeline
. It will notify the application of everything
that's happening (errors, end of stream, tags found, state changes, etc.)
by posting messages on its Bus
. The application needs to watch the
bus.
Playback can be initiated by setting the PlayBin2 to PLAYING state using
setState
or play
. Note that the state change will take place in
the background in a separate thread, when the function returns playback
is probably not happening yet and any errors might not have occured yet.
Applications using playbin should ideally be written to deal with things
completely asynchroneous.
When playback has finished (an EOS message has been received on the bus) or an error has occured (an ERROR message has been received on the bus) or the user wants to play a different track, playbin should be set back to READY or NULL state, then the input file/URI should be set to the new location and then playbin be set to PLAYING state again.
Seeking can be done using seek
on the playbin2 element.
Again, the seek will not be executed instantaneously, but will be done in a
background thread. When the seek call returns the seek will most likely still
be in process. An application may wait for the seek to finish (or fail) using
Element.getState(long)
with -1 as the timeout, but this will block the user
interface and is not recommended at all.
Applications may query the current position and duration of the stream
via Pipeline.queryPosition()
and Pipeline.queryDuration()
and
setting the format passed to Format.TIME
. If the query was successful,
the duration or position will have been returned in units of nanoseconds.
Modifier and Type | Class and Description |
---|---|
static interface |
PlayBin2.ABOUT_TO_FINISH
Signal emitted when the current uri is about to finish.
|
static interface |
PlayBin2.AUDIO_CHANGED
Signal is emitted whenever the number or order of the audio streams has changed.
|
static interface |
PlayBin2.AUDIO_TAGS_CHANGED
Signal is emitted whenever the tags of an audio stream have changed.
|
static interface |
PlayBin2.SOURCE_SETUP
This signal is emitted after the source element has been created,
so it can be configured by setting additional properties (e.g.
|
static interface |
PlayBin2.TEXT_CHANGED
Signal is emitted whenever the number or order of the audio streams has changed.
|
static interface |
PlayBin2.TEXT_TAGS_CHANGED
Signal is emitted whenever the tags of a text stream have changed.
|
static interface |
PlayBin2.VIDEO_CHANGED
Signal is emitted whenever the number or order of the video streams has changed.
|
static interface |
PlayBin2.VIDEO_TAGS_CHANGED
Signal is emitted whenever the tags of a video stream have changed.
|
Bin.DO_LATENCY, Bin.ELEMENT_ADDED, Bin.ELEMENT_REMOVED
Element.NO_MORE_PADS, Element.PAD_ADDED, Element.PAD_REMOVED
GObject.GCallback, GObject.NOTIFY
NativeObject.Initializer
Modifier and Type | Field and Description |
---|---|
static String |
GST_NAME |
static String |
GTYPE_NAME |
DEBUG_GRAPH_SHOW_ALL, DEBUG_GRAPH_SHOW_CAPS_DETAILS, DEBUG_GRAPH_SHOW_MEDIA_TYPE, DEBUG_GRAPH_SHOW_NON_DEFAULT_PARAMS, DEBUG_GRAPH_SHOW_STATES
defaultInit, ownsHandle
Constructor and Description |
---|
PlayBin2(NativeObject.Initializer init)
Creates a new PlayBin2 proxy.
|
PlayBin2(String name)
Creates a new PlayBin2.
|
PlayBin2(String name,
URI uri)
Creates a new PlayBin2.
|
Modifier and Type | Method and Description |
---|---|
void |
connect(PlayBin2.ABOUT_TO_FINISH listener)
Adds a listener for the
about-to-finish signal |
void |
connect(PlayBin2.AUDIO_CHANGED listener)
Adds a listener for the
audio-changed signal |
void |
connect(PlayBin2.AUDIO_TAGS_CHANGED listener)
Adds a listener for the
audio-tags-changed signal |
void |
connect(PlayBin2.SOURCE_SETUP listener)
Adds a listener for the
source-setup signal |
void |
connect(PlayBin2.TEXT_CHANGED listener)
Adds a listener for the
audio-changed signal |
void |
connect(PlayBin2.TEXT_TAGS_CHANGED listener)
Adds a listener for the
audio-tags-changed signal |
void |
connect(PlayBin2.VIDEO_CHANGED listener)
Adds a listener for the
video-changed signal |
void |
connect(PlayBin2.VIDEO_TAGS_CHANGED listener)
Adds a listener for the
video-tags-changed signal |
void |
disconnect(PlayBin2.ABOUT_TO_FINISH listener)
Removes a listener for the
about-to-finish signal |
void |
disconnect(PlayBin2.AUDIO_CHANGED listener)
Removes a listener for the
audio-changed signal |
void |
disconnect(PlayBin2.AUDIO_TAGS_CHANGED listener)
Removes a listener for the
audio-tags-changed signal |
void |
disconnect(PlayBin2.SOURCE_SETUP listener)
Removes a listener for the
source-setup signal |
void |
disconnect(PlayBin2.TEXT_CHANGED listener)
Removes a listener for the
text-changed signal |
void |
disconnect(PlayBin2.TEXT_TAGS_CHANGED listener)
Removes a listener for the
text-tags-changed signal |
void |
disconnect(PlayBin2.VIDEO_CHANGED listener)
Removes a listener for the
video-changed signal |
void |
disconnect(PlayBin2.VIDEO_TAGS_CHANGED listener)
Removes a listener for the
video-tags-changed signal |
double |
getVideoSinkFrameRate()
Retrieves the framerate from the caps of the video sink's pad.
|
Dimension |
getVideoSize()
Retrieves the width and height of the video frames configured in the caps
of the video sink's pad.
|
double |
getVolume()
Gets the current volume.
|
int |
getVolumePercent()
Get the current volume.
|
void |
setAudioSink(Element element)
Sets the audio output Element.
|
void |
setInputFile(File file)
Sets the media file to play.
|
void |
setURI(URI uri)
Sets the media URI to play.
|
void |
setVideoSink(Element element)
Sets the video output Element.
|
void |
setVisualization(Element element)
Sets the visualization output Element.
|
void |
setVolume(double volume)
Sets the audio playback volume.
|
void |
setVolumePercent(int percent)
Set the volume for the PlayBin.
|
getAutoFlushBus, getBus, getClock, launch, launch, queryDuration, queryDuration, queryDuration, queryPosition, queryPosition, queryPosition, querySegment, querySegment, seek, seek, seek, setAutoFlushBus, setClock, useClock
add, addMany, connect, connect, connect, debugToDotFile, debugToDotFile, disconnect, disconnect, disconnect, getElementByInterface, getElementByName, getElementByNameRecurseUp, getElements, getElementsRecursive, getElementsSorted, getSinks, getSources, launch, remove, removeMany
addPad, connect, connect, connect, disconnect, disconnect, disconnect, getBaseTime, getFactory, getPad, getPads, getRequestPad, getSinkPads, getSrcPads, getStartTime, getState, getState, getState, getState, getStaticPad, isPlaying, link, link, linkMany, linkPads, linkPadsFiltered, makeRawElement, pause, play, postMessage, ready, releaseRequestPad, removePad, sendEvent, setBaseTime, setCaps, setLockedState, setStartTime, setState, stop, syncStateWithParent, unlink, unlinkMany, unlinkPads
addListenerProxy, getName, getParent, initializer, initializer, ref, removeListenerProxy, setName, steal, toString, unref
addCallback, connect, connect, connect, connect, disconnect, disconnect, disconnect, disposeNativeHandle, emit, emit, g_signal_connect, get, getPointer, getPropertyDefaultValue, getPropertyMaximumValue, getPropertyMinimumValue, getType, getType, getTypeName, invalidate, listPropertyNames, removeCallback, set
classFor, disown, dispose, equals, finalize, getNativeAddress, handle, hashCode, initializer, instanceFor, isDisposed, nativeValue, objectFor, objectFor, objectFor, objectFor
public static final String GST_NAME
public static final String GTYPE_NAME
public PlayBin2(String name)
name
- The name used to identify this pipeline.public PlayBin2(String name, URI uri)
name
- The name used to identify this pipeline.uri
- The URI of the media file to load.public PlayBin2(NativeObject.Initializer init)
init
- proxy initialization argspublic void setInputFile(File file)
file
- The File
to play.public void setAudioSink(Element element)
To disable audio output, call this method with a null argument.
element
- The element to use for audio output.public void setVideoSink(Element element)
To disable video output, call this method with a null argument.
element
- The element to use for video output.public void setVisualization(Element element)
element
- The element to use for visualization.public void setVolumePercent(int percent)
percent
- Percentage (between 0 and 100) to set the volume to.public int getVolumePercent()
public void setVolume(double volume)
volume
- value between 0.0 and 1.0 with 1.0 being full volume.public double getVolume()
public double getVideoSinkFrameRate()
public Dimension getVideoSize()
public void connect(PlayBin2.ABOUT_TO_FINISH listener)
about-to-finish
signalpublic void disconnect(PlayBin2.ABOUT_TO_FINISH listener)
about-to-finish
signallistener
- The listener that was previously added.public void connect(PlayBin2.VIDEO_CHANGED listener)
video-changed
signalpublic void disconnect(PlayBin2.VIDEO_CHANGED listener)
video-changed
signallistener
- The listener that was previously added.public void connect(PlayBin2.AUDIO_CHANGED listener)
audio-changed
signalpublic void disconnect(PlayBin2.AUDIO_CHANGED listener)
audio-changed
signallistener
- The listener that was previously added.public void connect(PlayBin2.TEXT_CHANGED listener)
audio-changed
signalpublic void disconnect(PlayBin2.TEXT_CHANGED listener)
text-changed
signallistener
- The listener that was previously added.public void connect(PlayBin2.VIDEO_TAGS_CHANGED listener)
video-tags-changed
signalpublic void disconnect(PlayBin2.VIDEO_TAGS_CHANGED listener)
video-tags-changed
signallistener
- The listener that was previously added.public void connect(PlayBin2.AUDIO_TAGS_CHANGED listener)
audio-tags-changed
signalpublic void disconnect(PlayBin2.AUDIO_TAGS_CHANGED listener)
audio-tags-changed
signallistener
- The listener that was previously added.public void connect(PlayBin2.TEXT_TAGS_CHANGED listener)
audio-tags-changed
signalpublic void disconnect(PlayBin2.TEXT_TAGS_CHANGED listener)
text-tags-changed
signallistener
- The listener that was previously added.public void connect(PlayBin2.SOURCE_SETUP listener)
source-setup
signalpublic void disconnect(PlayBin2.SOURCE_SETUP listener)
source-setup
signallistener
- The listener that was previously added.Copyright © 2014. All rights reserved.