Most visited

Recently visited

Added in API level 16

MediaSyncEvent

public class MediaSyncEvent
extends Object

java.lang.Object
   ↳ android.media.MediaSyncEvent


The MediaSyncEvent class defines events that can be used to synchronize playback or capture actions between different players and recorders.

For instance, startRecording(MediaSyncEvent) is used to start capture only when the playback on a particular audio session is complete. The audio session ID is retrieved from a player (e.g MediaPlayer, AudioTrack or ToneGenerator) by use of the getAudioSessionId() method.

Summary

Constants

int SYNC_EVENT_NONE

No sync event specified.

int SYNC_EVENT_PRESENTATION_COMPLETE

The corresponding action is triggered only when the presentation is completed (meaning the media has been presented to the user) on the specified session.

Public methods

static MediaSyncEvent createEvent(int eventType)

Creates a synchronization event of the sepcified type.

int getAudioSessionId()

Gets the synchronization event audio session ID.

int getType()

Gets the synchronization event type.

MediaSyncEvent setAudioSessionId(int audioSessionId)

Sets the event source audio session ID.

Inherited methods

From class java.lang.Object

Constants

SYNC_EVENT_NONE

Added in API level 16
int SYNC_EVENT_NONE

No sync event specified. When used with a synchronized playback or capture method, the behavior is equivalent to calling the corresponding non synchronized method.

Constant Value: 0 (0x00000000)

SYNC_EVENT_PRESENTATION_COMPLETE

Added in API level 16
int SYNC_EVENT_PRESENTATION_COMPLETE

The corresponding action is triggered only when the presentation is completed (meaning the media has been presented to the user) on the specified session. A synchronization of this type requires a source audio session ID to be set via {@link #setAudioSessionId(int) method.

Constant Value: 1 (0x00000001)

Public methods

createEvent

Added in API level 16
MediaSyncEvent createEvent (int eventType)

Creates a synchronization event of the sepcified type.

The type specifies which kind of event is monitored. For instance, event SYNC_EVENT_PRESENTATION_COMPLETE corresponds to the audio being presented to the user on a particular audio session.

Parameters
eventType int: the synchronization event type.
Returns
MediaSyncEvent the MediaSyncEvent created.
Throws
IllegalArgumentException

getAudioSessionId

Added in API level 16
int getAudioSessionId ()

Gets the synchronization event audio session ID.

Returns
int the synchronization audio session ID. The returned audio session ID is 0 if it has not been set.

getType

Added in API level 16
int getType ()

Gets the synchronization event type.

Returns
int the synchronization event type.

setAudioSessionId

Added in API level 16
MediaSyncEvent setAudioSessionId (int audioSessionId)

Sets the event source audio session ID.

The audio session ID specifies on which audio session the synchronization event should be monitored. It is mandatory for certain event types (e.g. SYNC_EVENT_PRESENTATION_COMPLETE). For instance, the audio session ID can be retrieved via getAudioSessionId() when monitoring an event on a particular MediaPlayer.

Parameters
audioSessionId int: the audio session ID of the event source being monitored.
Returns
MediaSyncEvent the MediaSyncEvent the method is called on.
Throws
IllegalArgumentException

Hooray!