Back to Exoplayer

SntpClient (ExoPlayer library)

docs/doc/reference/com/google/android/exoplayer2/util/SntpClient.html

latest6.1 KB
Original Source

Package com.google.android.exoplayer2.util

Class SntpClient


[@Deprecated](https://developer.android.com/reference/java/lang/Deprecated.html "class or interface in java.lang")public final classSntpClientextends[Object](https://developer.android.com/reference/java/lang/Object.html "class or interface in java.lang")

Deprecated. com.google.android.exoplayer2 is deprecated. Please migrate to androidx.media3 (which contains the same ExoPlayer code). See the migration guide for more details, including a script to help with the migration.

Static utility to retrieve the device time offset using SNTP.

Based on the Android framework SntpClient.

Nested Class Summary

Nested Classes | Modifier and Type | Class | Description | | --- | --- | --- | | static interface | SntpClient.InitializationCallback | Deprecated.

Callback for calls to initialize(Loader, InitializationCallback). |

Field Summary

Fields | Modifier and Type | Field | Description | | --- | --- | --- | | static String | DEFAULT_NTP_HOST | Deprecated.

The default NTP host address used to retrieve getElapsedRealtimeOffsetMs(). |

Method Summary

All Methods Static Methods Concrete Methods Deprecated Methods | Modifier and Type | Method | Description | | --- | --- | --- | | static long | getElapsedRealtimeOffsetMs() | Deprecated.

Returns the offset between SystemClock.elapsedRealtime() and the NTP server time in milliseconds, or C.TIME_UNSET if isInitialized() returns false. | | static String | getNtpHost() | Deprecated.

Returns the NTP host address used to retrieve getElapsedRealtimeOffsetMs(). | | static void | initialize​(Loader loader, SntpClient.InitializationCallback callback) | Deprecated.

Starts loading the device time offset. | | static boolean | isInitialized() | Deprecated.

Returns whether the device time offset has already been loaded. | | static void | setNtpHost​(String ntpHost) | Deprecated.

Sets the NTP host address used to retrieve getElapsedRealtimeOffsetMs(). |

- 

Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail

- 

DEFAULT_NTP_HOST

public static final[String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")DEFAULT_NTP_HOST

Deprecated.

The default NTP host address used to retrieve getElapsedRealtimeOffsetMs(). See Also:Constant Field Values

Method Detail

- 

getNtpHost

public static[String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")getNtpHost()

Deprecated.

Returns the NTP host address used to retrieve getElapsedRealtimeOffsetMs().

- 

setNtpHost

public static void setNtpHost​([String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")ntpHost)

Deprecated.

Sets the NTP host address used to retrieve getElapsedRealtimeOffsetMs().

The default is DEFAULT_NTP_HOST.

If the new host address is different from the previous one, the NTP client will be isInitialized() uninitialized} again.

Parameters:ntpHost - The NTP host address.

- 

isInitialized

public static boolean isInitialized()

Deprecated.

Returns whether the device time offset has already been loaded.

If false, use initialize(Loader, InitializationCallback) to start the initialization.

- 

getElapsedRealtimeOffsetMs

public static long getElapsedRealtimeOffsetMs()

Deprecated.

Returns the offset between SystemClock.elapsedRealtime() and the NTP server time in milliseconds, or C.TIME_UNSET if isInitialized() returns false.

The offset is calculated as ntpServerTime - deviceElapsedRealTime.

- 

initialize

public static void initialize​(@Nullable[Loader](../upstream/Loader.html "class in com.google.android.exoplayer2.upstream")loader,
                              @Nullable[SntpClient.InitializationCallback](SntpClient.InitializationCallback.html "interface in com.google.android.exoplayer2.util")callback)

Deprecated.

Starts loading the device time offset. Parameters:loader - A Loader to use for loading the time offset, or null to create a new one.callback - An optional SntpClient.InitializationCallback to be notified when the time offset has been initialized or initialization failed.