|
Copyright 2008 Motorola Inc. and Nokia Corporation. All Rights Reserved. Specification License |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface TimerEventsControl
TimerEventsControl
extends the MMAPI Player
Control
to provide information about the progress of the media playback. It helps
the application to synchronize its actions to the played content.
TimerEventsControl
can work in three modes. In interval mode
(INTERVAL_MODE
) the media player sends events constantly. Rate of the events is set by the application.
In scheduled event mode (SCHEDULED_MODE
) the media player sends events according to
times specified by the application. In INTERVAL_AND_SCHEDULED_MODE
the control acts like in interval and scheduled
event modes at the same time.
In all modes, the time refers to media time of the Player
. Mode is selected by setMode(int mode)
.
The default values for TimerEventsControl
are: mode is INTERVAL_MODE
,
interval is 1 second (1000000 microseconds) and control is not enabled.
Interval is set in microseconds by setInterval(long interval)
. The minimum supported interval can be
queried by getMinInterval()
.
For instance, if interval is set to 500000 microseconds and media player is started, an event will be
sent after 0.5s, 1.0s, 1.5s and so on. Greatest minimum interval is 1 second and setting the interval to whole
seconds is guaranteed to work despite the actual minimum interval.
Rate of events is related to the media time, not real time. For instance, if in the previous example the media is played in double speed, the events come in after 0.25s, 0.5s, 0.75s and so on.
The media engine can align the sending of the events in relation to the media time. For instance, if the interval ise set to 1000000 microseconds when the media time is 0.750 seconds, the time stamp event can come at 1s, 2s and so on. Interval only specifies the rate of the events. The media player can decide the exact time when the first event is sent but it will be sent within the real time (not media time) passing 2 * the minimum interval despite the playback speed of the player.
Player
's media time or to receive constant synchronization events.
Events are set individually by addScheduledEvent(long time)
or by setting an array of them by
addScheduledEvents(long[] time)
, and they can be removed by removeScheduledEvent(long time)
or by removeAllScheduledEvents()
.
Time of the scheduled events when set is not evaluated except that the ones referring to past are ignored. However,
it can not be guaranteed that the events are received exactly when they are timed. Implementation can still align the time
to send the event to its own internal clock resolution. In addition, sending of events can be delayed in cases where several events
needs to be sent within very short time frame. In practice, applications probably don't notice any difference even when events
sometimes are delivered late.
Change to INTERVAL_MODE
removes all scheduled events.
readNextEvent()
.
When event occurs the method returns the time of the event. Time equals the mediaTime
of the Player
.
For scheduled events the method returns the time the event was scheduled for even if the event in practice takes place later than
that.
TimerEventsControl
buffers one event. When an event occurs and application has not called readNextEvent
the
event is placed in the buffer. If multiple events occur only the latest is buffered. The other ones are missed.
readNextEvent()
is a blocking method that returns
For instance, TimerEventsControl
is enabled in INTERVAL_MODE
with 1 second interval (1000000 µs). Therefore,
an event is delivered in every one seconds. First call to readNextEvent()
at 0.5 s would return when media player passes
1 second mark. If the first call is done at 5.5 s the method would return immediately with long value 5000000. (Assuming that media player
does not align the times according to it's internal clock)
Field Summary | |
---|---|
static int |
INTERVAL_AND_SCHEDULED_MODE
|
static int |
INTERVAL_MODE
|
static int |
SCHEDULED_MODE
|
Method Summary | |
---|---|
void |
addScheduledEvent(long time)
Add a scheduled event time. |
void |
addScheduledEvents(long[] times)
Add an array of scheduled event times. |
long |
getInterval()
Gets the interval. |
long |
getMinInterval()
Gets the minimum supported interval. |
int |
getMode()
Gets the current mode. |
int |
getScheduledEventCount()
Gets the number of scheduled events.. |
long[] |
getScheduledEvents()
Get all scheduled events. |
boolean |
isEnabled()
Queries the status of the sending of the timer event. |
long |
readNextEvent()
Reads the next notification from the event buffer. |
void |
removeAllScheduledEvents()
Remove all scheduled events. |
void |
removeScheduledEvent(long time)
Remove scheduled event. |
void |
setEnabled(boolean enable)
Enables the sending of timer events. |
long |
setInterval(long interval)
Sets the interval to send events about the progress of the playback. |
void |
setMode(int mode)
Sets the mode. |
Field Detail |
---|
static final int INTERVAL_AND_SCHEDULED_MODE
static final int INTERVAL_MODE
static final int SCHEDULED_MODE
Method Detail |
---|
void addScheduledEvent(long time) throws java.lang.IllegalArgumentException
time
If the scheduled event time that is less than current media time
or if the control is in INTERVAL_MODE
mode the method call is be ignored.
time
- time of the scheduled notification time in microseconds.
java.lang.IllegalArgumentException
- if time
is less than minimum interval away from existing scheduled events.void addScheduledEvents(long[] times) throws java.lang.IllegalArgumentException
times
Times in the array that are less than current media time are ignored.
If the control is in INTERVAL_MODE
mode the method call is be ignored.
times
- array of scheduled event times in microseconds. Times in the array don't need to be in any specific order.
java.lang.IllegalArgumentException
- if any time in times
is less than minimum interval away from existing scheduled events
or from other events in times
.
java.lang.NullPointerException
- if times
is null
.long getInterval()
long getMinInterval()
int getMode()
int getScheduledEventCount()
0
if in INTERVAL_MODE
mode.long[] getScheduledEvents()
INTERVAL_MODE
an empty array is returned.boolean isEnabled()
long readNextEvent()
void removeAllScheduledEvents()
INTERVAL_MODE
mode the method call is ignored.
void removeScheduledEvent(long time)
time
- time of the removed scheduled event in microseconds.
If a scheduled event to match the time
does not exist or the control is in
INTERVAL_MODE
mode the method call is ignored.void setEnabled(boolean enable)
enable
- true
to enable, false
to disable.long setInterval(long interval)
interval
- in microseconds. Implementation can round the interval
to closest appropriate interval.
Intervals that are multiplications of the minimum interval or multiplications of 1000000 (i.e. whole seconds)
will not be rounded.
java.lang.IllegalArgumentException
- if the given value is less than minimum interval.void setMode(int mode)
INTERVAL_MODE
clears the buffer for scheduled events.
java.lang.IllegalArgumentException
- if mode
is not INTERVAL_MODE
,
SCHEDULED_MODE
or INTERVAL_AND_SCHEDULED_MODE
.
|
Copyright 2008 Motorola Inc. and Nokia Corporation. All Rights Reserved. Specification License |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |