Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)
Android APIs
public class

MediaSyncEvent

extends Object
java.lang.Object
   ↳ android.media.MediaSyncEvent

Class Overview

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.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final 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)

public static final 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

public static 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 the synchronization event type.
Returns
  • the MediaSyncEvent created.

public int getAudioSessionId ()

Gets the synchronization event audio session ID.

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

public int getType ()

Gets the synchronization event type.

Returns
  • the synchronization event type.

public 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 the audio session ID of the event source being monitored.
Returns
  • the MediaSyncEvent the method is called on.