public class Handler extends Object implements ServiceMediaHandler, Player
ServiceMediaHandler represents an handler of service
components which are real time media sharing the same clock. A
ServiceMediaHandler is associated with the
Service currently selected in the
ServiceContext from which it was obtained.ServiceContext,
MediaSelectControlLATENCY_UNKNOWN, Prefetched, Prefetching, Realized, Realizing, Started, UnrealizedDURATION_UNBOUNDED, DURATION_UNKNOWN| Constructor and Description |
|---|
Handler(Locator locator,
ServiceContextImpl context) |
| Modifier and Type | Method and Description |
|---|---|
void |
addController(Controller newController)
Assume control of another
Controller. |
void |
addControllerListener(ControllerListener listener)
Specify a
ControllerListener to which
this Controller will send events. |
void |
close()
Release all resources and cease all activity.
|
void |
deallocate()
Abort the current operation and cease any activity that
consumes system resources.
|
Control |
getControl(String forName)
Get the
Control that supports the
class or interface specified. |
Component |
getControlPanelComponent()
Obtain the
Component that provides the default user
interface for controlling this Player. |
Control[] |
getControls()
Get a list of the
Control objects that
this Controller supports. |
Time |
getDuration()
Get the duration of the media represented
by this object.
|
GainControl |
getGainControl()
Obtain the object for controlling this
Player's
audio gain. |
long |
getMediaNanoseconds()
Get this
Clock's current media time
in nanoseconds. |
Time |
getMediaTime()
Get this
Clock's current media time. |
float |
getRate()
Get the current temporal scale factor.
|
Locator[] |
getServiceContentLocators()
Reports the portions of the service on which this handler operates.
|
ServiceContextImpl |
getServiceContext() |
Locator |
getServiceLocator() |
Time |
getStartLatency()
Get the
Controller's start latency in nanoseconds. |
int |
getState()
Get the current state of this
Controller. |
Time |
getStopTime()
Get the last value successfully set by
setStopTime. |
Time |
getSyncTime()
Get the current media time or the time until this
Clock will synchronize to its TimeBase. |
int |
getTargetState()
Get the current target state of this
Controller. |
TimeBase |
getTimeBase()
Get the
TimeBase that this Clock is using. |
Component |
getVisualComponent()
Obtain the display
Component for this Player. |
Time |
mapToTimeBase(Time t)
Get the
TimeBase time corresponding to the specified media time. |
void |
prefetch()
Process as much data as necessary
to reduce the
Controller's start latency to the shortest possible time. |
void |
realize()
Construct the media dependent portions of the
Controller. |
void |
removeController(Controller oldController)
Stop controlling a
Controller. |
void |
removeControllerListener(ControllerListener listener)
Remove the specified listener from this
Controller's
listener list. |
void |
setMediaTime(Time now)
Set the
Clock's media time. |
float |
setRate(float factor)
Set the temporal scale factor.
|
void |
setSource(DataSource source)
Set the media source the
MediaHandler
should use to obtain content. |
void |
setStopTime(Time stopTime)
Set the media time at which you want the
Clock
to stop. |
void |
setTimeBase(TimeBase master)
Set the
TimeBase for this Clock. |
void |
start()
Start the
Player as soon as possible. |
void |
stop()
Stop the
Clock. |
void |
syncStart(Time at)
Synchronize the current media time to the specified
time-base time and start the
Clock. |
boolean |
validHandler() |
public Handler(Locator locator, ServiceContextImpl context)
public Locator getServiceLocator()
public ServiceContextImpl getServiceContext()
public boolean validHandler()
public Locator[] getServiceContentLocators()
getServiceContentLocators in interface ServiceContentHandlerLocators representing the portions
of the service on which this handler operates.ServiceContext.select(Locator[] components)public Component getVisualComponent()
Component for this Player.
The display Component is where visual media
is rendered.
If this Player has no visual component,
getVisualComponent returns null.
For example, getVisualComponent might return
null if the Player only plays audio.getVisualComponent in interface PlayerComponent for this
Player.public GainControl getGainControl()
Player's
audio gain.
If this player does not have a
GainControl, getGainControl returns
null.
For example, getGainControl might return
null if the Player does not play audio data.getGainControl in interface PlayerGainControl object for this
Player.public Component getControlPanelComponent()
Component that provides the default user
interface for controlling this Player.
If this Player has no default control panel,
getControlPanelComponent returns null.getControlPanelComponent in interface PlayerPlayer.public void start()
Player as soon as possible.
The start method attempts to transition the
Player to the Started state.
If the Player has not been Realized or
Prefetched, start automatically performs
those actions. The appropriate events
are posted as the Player moves through each state.public void addController(Controller newController) throws IncompatibleTimeBaseException
Controller.addController in interface PlayernewController - The Controller to be managed.IncompatibleTimeBaseException - Thrown if the added
Controller cannot take this
Player's TimeBase.public void removeController(Controller oldController)
Controller.removeController in interface PlayeroldController - The Controller to stop managing.public void setSource(DataSource source) throws IOException, IncompatibleSourceException
MediaHandler
should use to obtain content.setSource in interface MediaHandlersource - The DataSource used
by this MediaHandler.IOException - Thrown if there is an error
using the DataSourceIncompatibleSourceException - Thrown if
this MediaHandler cannot make use
of the DataSource.public int getState()
Controller.
The state is an integer constant as defined above.
Note: A race condition can occur between the return of this method and the execution of a state changing method.
getState in interface ControllerController's current state.public int getTargetState()
Controller.
The state is an integer constant as defined above.
Note: A race condition can occur between the return of this method and the execution of a state changing method.
getTargetState in interface ControllerController's current target state.public void realize()
Controller.
This can require examining media data and might
take some time to complete.
The realize method puts the Controller into the Realizing state and returns immediately.
When realize is complete and the Controller is in the
Realized state, the Controller posts a
RealizeCompleteEvent.
realize in interface Controllerpublic void prefetch()
Controller's start latency to the shortest possible time.
This typically requires examining media data and takes some
time to complete.
The prefetch method puts the Controller into the Prefetching state and returns immediately.
When Prefetching is complete and the Controller is in
the Prefetched state, the Controller posts
a PrefetchCompleteEvent.
prefetch in interface Controllerpublic void deallocate()
Controller is not yet
Realized,
it returns to the Unrealized state. Otherwise, the Controller
returns to the Realized state.
It is illegal to call deallocate on a Started Controller.
A ClockStartedError is thrown if deallocate
is called and the Controller is in the Started state.
deallocate in interface Controllerpublic void close()
close method indicates that the Controller will
no longer be used, and the Controller can
shut itself down.
A ControllerClosedEvent is posted.
Methods invoked on a closed Controller
might throw errors.close in interface Controllerpublic Time getStartLatency()
Controller's start latency in nanoseconds. The start latency represents a
worst-case estimate of the amount of time it will take
to present the first frame of data.
This method is useful for determining how far in advance the
syncStart method must be invoked to ensure
that media will be
rendered at the specified start time.
For a Controller that has a variable start latency,
the value returned represents the maximum possible
start latency. If you call getStartLatency on a Controller that isn't Prefetched
and getStartLatency returns LATENCY_UNKNOWN, calling
prefetch and then calling getStartLatency again after the Controller posts
a PrefetchCompleteEvent might
return a more accurate estimate.
If getStartLatency still returns LATENCY_UNKNOWN,
the start latency is indeterminate and you might not be able to use
syncStart to
synchronize the Controller with other Controllers.
Note: In most cases, the value returned by
getStartLatency will change once the
Controller is Prefetched.
getStartLatency in interface Controllerpublic Control[] getControls()
Control objects that
this Controller supports.
If there are no controls, an array of length zero
is returned.getControls in interface ControllerController Controls.public Control getControl(String forName)
Control that supports the
class or interface specified. The full class
or interface name should be specified.
Null is returned if the Control
is not supported.getControl in interface ControllerControl for the class or interface
name.public void addControllerListener(ControllerListener listener)
ControllerListener to which
this Controller will send events.
A Controller can have multiple
ControllerListeners.addControllerListener in interface Controllerlistener - The listener to which the Controller
will post events.public void removeControllerListener(ControllerListener listener)
Controller's
listener list.removeControllerListener in interface Controllerlistener - The listener that has been receiving events from this
Controller.public Time getDuration()
getDuration returns DURATION_UNKNOWN.getDuration in interface DurationTime object representing the duration or DURATION_UNKNOWN.public void setTimeBase(TimeBase master) throws IncompatibleTimeBaseException
TimeBase for this Clock.
This method can only be called on a
Stopped Clock.
A ClockStartedError is thrown if
setTimeBase is called on a Started
Clock.
A Clock has a default TimeBase that
is determined by the implementation.
To reset a Clock to its default
TimeBase, call setTimeBase(null).
setTimeBase in interface Clockmaster - The new TimeBase or null to reset the Clock
to its default TimeBase.IncompatibleTimeBaseException - Thrown if
the Clock can't use the specified TimeBase.public void syncStart(Time at)
Clock.
The syncStart method sets the time-base start-time,
and puts the Clock in the Started state.
This method can only be called on a
Stopped Clock.
A ClockStartedError is thrown if
setTimeBase is called on a Started
Clock.public void stop()
Clock.
Calling stop releases the Clock from
synchronization with the TimeBase.
After this request is issued, the Clock is in the
Stopped state.
If stop is called on
a Stopped Clock, the request is ignored.public void setStopTime(Time stopTime)
Clock
to stop.
The Clock will stop when its media time
passes the stop-time.
To clear the stop time, set it to: Clock.RESET.
You can always call setStopTime on a Stopped
Clock.
On a Started Clock, the stop-time can only
be set once.
A StopTimeSetError is thrown if setStopTime
is called and the media stop-time has already been set.
setStopTime in interface ClockstopTime - The time at which you want the
Clock to stop, in media time.public Time getStopTime()
setStopTime.
Returns the constant Clock.RESET if no stop time is set.
(Clock.RESET is the default stop time.)getStopTime in interface Clockpublic void setMediaTime(Time now)
Clock's media time.
This method can only be called on
a Stopped Clock.
A ClockStartedError is thrown if
setMediaTime is called on a Started
Clock.setMediaTime in interface Clocknow - The new media time.public Time getMediaTime()
Clock's current media time.
A Started Clock's media time
is based on its TimeBase
and rate, as described in Starting a Clock.getMediaTime in interface Clockpublic long getMediaNanoseconds()
Clock's current media time
in nanoseconds.getMediaNanoseconds in interface Clockpublic Time getSyncTime()
Clock will synchronize to its TimeBase.
The getSyncTime method is used by Players and
advanced applet writers to synchronize Clocks.
Like getMediaTime, this method returns
the Clock's current media time,
which is based on its TimeBase and rate.
However, when syncStart is used to start
the Clock, getSyncTime performs a countdown
to the time-base start-time, returning the time remaining until
the time-base start-time.
Once the TimeBase reaches the
time-base start-time, getSyncTime
and getMediaTime will return the same value.
getSyncTime in interface Clockpublic TimeBase getTimeBase()
TimeBase that this Clock is using.getTimeBase in interface Clockpublic Time mapToTimeBase(Time t) throws ClockStoppedException
TimeBase time corresponding to the specified media time.mapToTimeBase in interface Clockt - The media time to map from.ClockStoppedException - Thrown if mapToTimeBase is called on a Stopped
Clock.public float getRate()
Clock's media time
and its TimeBase.
For example, a rate of 2.0 indicates that media time
will pass twice as fast as the TimeBase time once
the Clock
starts. Similarly, a negative rate indicates that
the Clock runs in the opposite direction of its TimeBase.
All Clocks are
guaranteed to support a rate of 1.0, the default rate. Clocks are not required
to support any other rate.
public float setRate(float factor)
The setRate method returns the actual rate set by the
Clock. Clocks should set their rate as close to
the requested
value as possible, but are not required to set the rate to the exact
value of any argument other than 1.0. A Clock is only guaranteed to set
its rate exactly to 1.0.
You can only call this method on a Stopped Clock. A
ClockStartedError is thrown if setRate is called on a Started Clock.
Copyright © 2012 code4tv.com. All Rights Reserved.