SyncParams
class SyncParams
kotlin.Any | |
↳ | android.media.SyncParams |
Structure for common A/V sync params. Used by MediaSync
{link MediaSync#getSyncParams()} and {link MediaSync#setSyncParams(SyncParams)} to control A/V sync behavior.
audio adjust mode: select handling of audio track when changing playback speed due to sync.
-
SyncParams#AUDIO_ADJUST_MODE_DEFAULT
: System will determine best handling. -
SyncParams#AUDIO_ADJUST_MODE_STRETCH
: Change the speed of audio playback without altering its pitch. -
SyncParams#AUDIO_ADJUST_MODE_RESAMPLE
: Change the speed of audio playback by resampling the audio.
sync source: select clock source for sync.
-
SyncParams#SYNC_SOURCE_DEFAULT
: System will determine best selection. -
SyncParams#SYNC_SOURCE_SYSTEM_CLOCK
: Use system clock for sync source. -
SyncParams#SYNC_SOURCE_AUDIO
: Use audio track for sync source. -
SyncParams#SYNC_SOURCE_VSYNC
: Syncronize media to vsync.
tolerance: specifies the amount of allowed playback rate change to keep media in sync with the sync source. The handling of this depends on the sync source, but must not be negative, and must be less than one.
frameRate: initial hint for video frame rate. Used when sync source is vsync. Negative values can be used to clear a previous hint.
Summary
Constants | |
---|---|
static Int |
System will determine best handling of audio for playback rate adjustments. |
static Int |
Resample audio when playback rate must be adjusted. |
static Int |
Time stretch audio when playback rate must be adjusted. |
static Int |
Use audio track for sync source. |
static Int |
Use the default sync source (default). |
static Int |
Use system monotonic clock for sync source. |
static Int |
Use vsync as the sync source. |
Public constructors | |
---|---|
Public methods | |
---|---|
SyncParams! |
Allows defaults to be returned for properties not set. |
Int |
Retrieves the audio adjust mode. |
Float |
Retrieves the video frame rate hint. |
Int |
Retrieves the sync source. |
Float |
Retrieves the tolerance factor. |
SyncParams! |
setAudioAdjustMode(audioAdjustMode: Int) Sets the audio adjust mode. |
SyncParams! |
setFrameRate(frameRate: Float) Sets the video frame rate hint to be used. |
SyncParams! |
setSyncSource(syncSource: Int) Sets the sync source. |
SyncParams! |
setTolerance(tolerance: Float) Sets the tolerance. |
Constants
AUDIO_ADJUST_MODE_DEFAULT
static val AUDIO_ADJUST_MODE_DEFAULT: Int
System will determine best handling of audio for playback rate adjustments.
Used by default. This will make audio play faster or slower as required by the sync source without changing its pitch; however, system may fall back to some other method (e.g. change the pitch, or mute the audio) if time stretching is no longer supported for the playback rate.
Value: 0
AUDIO_ADJUST_MODE_RESAMPLE
static val AUDIO_ADJUST_MODE_RESAMPLE: Int
Resample audio when playback rate must be adjusted.
This will make audio play faster or slower as required by the sync source by changing its pitch (making it lower to play slower, and higher to play faster.)
Value: 2
AUDIO_ADJUST_MODE_STRETCH
static val AUDIO_ADJUST_MODE_STRETCH: Int
Time stretch audio when playback rate must be adjusted.
This will make audio play faster or slower as required by the sync source without changing its pitch, as long as it is supported for the playback rate.
Value: 1
SYNC_SOURCE_AUDIO
static val SYNC_SOURCE_AUDIO: Int
Use audio track for sync source. This requires audio data and an audio track.
Value: 2
SYNC_SOURCE_DEFAULT
static val SYNC_SOURCE_DEFAULT: Int
Use the default sync source (default). If media has video, the sync renders to a surface that directly renders to a display, and tolerance is non zero (e.g. not less than 0.001) vsync source is used for clock source. Otherwise, if media has audio, audio track is used. Finally, if media has no audio, system clock is used.
Value: 0
SYNC_SOURCE_SYSTEM_CLOCK
static val SYNC_SOURCE_SYSTEM_CLOCK: Int
Use system monotonic clock for sync source.
Value: 1
See Also
SYNC_SOURCE_VSYNC
static val SYNC_SOURCE_VSYNC: Int
Use vsync as the sync source. This requires video data and an output surface that directly renders to the display, e.g. android.view.SurfaceView
This mode allows smoother playback experience by adjusting the playback speed to match the vsync rate, e.g. playing 30fps content on a 59.94Hz display. When using this mode, the tolerance should be set to greater than 0 (e.g. at least 1/1000), so that the playback speed can actually be adjusted.
This mode can also be used to play 25fps content on a 60Hz display using a 2:3 pulldown (basically playing the content at 24fps), which results on better playback experience on most devices. In this case the tolerance should be at least (1/24).
Value: 3
Public constructors
SyncParams
SyncParams()
Public methods
allowDefaults
fun allowDefaults(): SyncParams!
Allows defaults to be returned for properties not set. Otherwise a java.lang.IllegalArgumentException
exception is raised when getting those properties which have defaults but have never been set.
Return | |
---|---|
SyncParams! |
this SyncParams instance. |
getAudioAdjustMode
fun getAudioAdjustMode(): Int
Retrieves the audio adjust mode.
Return | |
---|---|
Int |
audio adjust mode Value is android.media.SyncParams#AUDIO_ADJUST_MODE_DEFAULT , android.media.SyncParams#AUDIO_ADJUST_MODE_STRETCH , or android.media.SyncParams#AUDIO_ADJUST_MODE_RESAMPLE |
Exceptions | |
---|---|
java.lang.IllegalStateException |
if the audio adjust mode is not set. |
getFrameRate
fun getFrameRate(): Float
Retrieves the video frame rate hint.
Return | |
---|---|
Float |
frame rate factor. A non-negative number representing the maximum deviation of the playback rate from the playback rate set. (abs(actual_rate - set_rate) / set_rate ), or a negative number representing the desire to clear a previous hint using these params. |
Exceptions | |
---|---|
java.lang.IllegalStateException |
if frame rate is not set. |
getSyncSource
fun getSyncSource(): Int
Retrieves the sync source.
Exceptions | |
---|---|
java.lang.IllegalStateException |
if the sync source is not set. |
getTolerance
fun getTolerance(): Float
Retrieves the tolerance factor.
Return | |
---|---|
Float |
tolerance factor. A non-negative number representing the maximum deviation of the playback rate from the playback rate set. (abs(actual_rate - set_rate) / set_rate ) |
Exceptions | |
---|---|
java.lang.IllegalStateException |
if tolerance is not set. |
setAudioAdjustMode
fun setAudioAdjustMode(audioAdjustMode: Int): SyncParams!
Sets the audio adjust mode.
Parameters | |
---|---|
audioAdjustMode |
Int: Value is android.media.SyncParams#AUDIO_ADJUST_MODE_DEFAULT , android.media.SyncParams#AUDIO_ADJUST_MODE_STRETCH , or android.media.SyncParams#AUDIO_ADJUST_MODE_RESAMPLE |
Return | |
---|---|
SyncParams! |
this SyncParams instance. |
setFrameRate
fun setFrameRate(frameRate: Float): SyncParams!
Sets the video frame rate hint to be used. By default the frame rate is unspecified.
Parameters | |
---|---|
frameRate |
Float: A non-negative number used as an initial hint on the video frame rate to be used when using vsync as the sync source. A negative number is used to clear a previous hint. |
Return | |
---|---|
SyncParams! |
this SyncParams instance. |
setSyncSource
fun setSyncSource(syncSource: Int): SyncParams!
Sets the sync source.
Return | |
---|---|
SyncParams! |
this SyncParams instance. |
setTolerance
fun setTolerance(tolerance: Float): SyncParams!
Sets the tolerance. The default tolerance is platform specific, but is never more than 1/24.
Parameters | |
---|---|
tolerance |
Float: A non-negative number representing the maximum deviation of the playback rate from the playback rate set. (abs(actual_rate - set_rate) / set_rate ) |
Return | |
---|---|
SyncParams! |
this SyncParams instance. |
Exceptions | |
---|---|
java.lang.IllegalArgumentException |
if the tolerance is negative, or not less than one. |