# Util

Artifact: [androidx.media3:media3-common](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/common/util/Util.java+class:androidx.media3.common.util.Util)

*** ** * ** ***


```
public final class Util
```

<br />

*** ** * ** ***

Miscellaneous utility methods.

## Summary

| ### Constants |
|---|---|
| `static final https://developer.android.com/reference/java/lang/String.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#DEVICE()` **This field is deprecated.** Use `https://developer.android.com/reference/android/os/Build.html#DEVICE` instead. <br /> |
| `static final https://developer.android.com/reference/java/lang/String.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#DEVICE_DEBUG_INFO()` A concise description of the device that it can be useful to log for debugging purposes. |
| `static final byte[]` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#EMPTY_BYTE_ARRAY()` An empty byte array. |
| `static final long[]` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#EMPTY_LONG_ARRAY()` An empty long array. |
| `static final https://developer.android.com/reference/java/lang/String.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#MANUFACTURER()` **This field is deprecated.** Use `https://developer.android.com/reference/android/os/Build.html#MANUFACTURER` instead. <br /> |
| `static final https://developer.android.com/reference/java/lang/String.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#MODEL()` **This field is deprecated.** Use `https://developer.android.com/reference/android/os/Build.html#MODEL` instead. <br /> |
| `static final int` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#SDK_INT()` **This field is deprecated.** Use `https://developer.android.com/reference/android/os/Build.VERSION.html#SDK_INT` instead. <br /> |

| ### Public methods |
|---|---|
| `static long` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#addWithOverflowDefault(long,long,long)(long x, long y, long overflowResult)` Returns the sum of two arguments, or a third argument if the result overflows. |
| `static boolean` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi @https://checkerframework.org/api/com/google/errorprone/annotations/InlineMe.html(replacement = "Objects.equals(o1, o2)", imports = [""java.util.Objects""]) [areEqual](https://developer.android.com/reference/androidx/media3/common/util/Util#areEqual(java.lang.Object,java.lang.Object))(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html o1, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html o2)` **This method is deprecated.** Use `https://developer.android.com/reference/java/util/Objects.html#equals(java.lang.Object, java.lang.Object)` instead. <br /> |
| `static int` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#binarySearchCeil(int[],int,boolean,boolean)( int[] array, int value, boolean inclusive, boolean stayInBounds )` Returns the index of the smallest element in `array` that is greater than (or optionally equal to) a specified `value`. |
| `static int` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#binarySearchCeil(long[],long,boolean,boolean)( long[] array, long value, boolean inclusive, boolean stayInBounds )` Returns the index of the smallest element in `array` that is greater than (or optionally equal to) a specified `value`. |
| `static int` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi <T extends https://developer.android.com/reference/java/lang/Comparable.html<T>> https://developer.android.com/reference/androidx/media3/common/util/Util#binarySearchCeil(java.util.List<? extends java.lang.Comparable<? super T>>,T,boolean,boolean)( https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/java/lang/Comparable.html<T>> list, T value, boolean inclusive, boolean stayInBounds )` Returns the index of the smallest element in `list` that is greater than (or optionally equal to) a specified value. |
| `static int` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#binarySearchFloor(int[],int,boolean,boolean)( int[] array, int value, boolean inclusive, boolean stayInBounds )` Returns the index of the largest element in `array` that is less than (or optionally equal to) a specified `value`. |
| `static int` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#binarySearchFloor(long[],long,boolean,boolean)( long[] array, long value, boolean inclusive, boolean stayInBounds )` Returns the index of the largest element in `array` that is less than (or optionally equal to) a specified `value`. |
| `static int` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi <T extends https://developer.android.com/reference/java/lang/Comparable.html<T>> https://developer.android.com/reference/androidx/media3/common/util/Util#binarySearchFloor(java.util.List<? extends java.lang.Comparable<? super T>>,T,boolean,boolean)( https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/java/lang/Comparable.html<T>> list, T value, boolean inclusive, boolean stayInBounds )` Returns the index of the largest element in `list` that is less than (or optionally equal to) a specified `value`. |
| `static int` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#binarySearchFloor(androidx.media3.common.util.LongArray,long,boolean,boolean)( https://developer.android.com/reference/androidx/media3/common/util/LongArray longArray, long value, boolean inclusive, boolean stayInBounds )` Returns the index of the largest element in `longArray` that is less than (or optionally equal to) a specified `value`. |
| `static T` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi @https://checkerframework.org/api/org/checkerframework/checker/nullness/qual/EnsuresNonNull.html(value = "#1") <T> https://developer.android.com/reference/androidx/media3/common/util/Util#castNonNull(T)(@https://developer.android.com/reference/androidx/annotation/Nullable T value)` Casts a nullable variable to a non-null variable without runtime null check. |
| `static T[]` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi @https://checkerframework.org/api/org/checkerframework/checker/nullness/qual/EnsuresNonNull.html(value = "#1") <T> https://developer.android.com/reference/androidx/media3/common/util/Util#castNonNullTypeArray(T[])(@https://developer.android.com/reference/androidx/media3/common/util/NullableType T[] value)` Casts a nullable type array to a non-null type array without runtime null check. |
| `static int` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#ceilDivide(int,int)(int numerator, int denominator)` Divides a `numerator` by a `denominator`, returning the ceiled result. |
| `static long` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#ceilDivide(long,long)(long numerator, long denominator)` Divides a `numerator` by a `denominator`, returning the ceiled result. |
| `static boolean` | `https://developer.android.com/reference/androidx/media3/common/util/Util#checkCleartextTrafficPermitted(androidx.media3.common.MediaItem...)(MediaItem[] mediaItems)` Returns whether it may be possible to load the URIs of the given media items based on the network security policy's cleartext traffic permissions. |
| `static void` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#closeQuietly(java.io.Closeable)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/io/Closeable.html closeable)` Closes a `https://developer.android.com/reference/java/io/Closeable.html`, suppressing any `https://developer.android.com/reference/java/io/IOException.html` that may occur. |
| `static int` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi @https://checkerframework.org/api/com/google/errorprone/annotations/InlineMe.html(replacement = "Long.compare(left, right)") [compareLong](https://developer.android.com/reference/androidx/media3/common/util/Util#compareLong(long,long))(long left, long right)` **This method is deprecated.** Use `https://developer.android.com/reference/java/lang/Long.html#compare(long, long)`. <br /> |
| `static double` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#constrainValue(double,double,double)(double value, double min, double max)` Constrains a value to the specified bounds. |
| `static float` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#constrainValue(float,float,float)(float value, float min, float max)` Constrains a value to the specified bounds. |
| `static int` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#constrainValue(int,int,int)(int value, int min, int max)` Constrains a value to the specified bounds. |
| `static long` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#constrainValue(long,long,long)(long value, long min, long max)` Constrains a value to the specified bounds. |
| `static boolean` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#contains(java.lang.Object[],java.lang.Object)(@https://developer.android.com/reference/androidx/media3/common/util/NullableType Object[] items, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html item)` Tests whether an `items` array contains an object equal to `item`, according to `https://developer.android.com/reference/java/lang/Object.html#equals(java.lang.Object)`. |
| `static boolean` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi <T> https://developer.android.com/reference/androidx/media3/common/util/Util#contains(android.util.SparseArray<T>,int)(https://developer.android.com/reference/android/util/SparseArray.html<T> sparseArray, int key)` Tests whether a `https://developer.android.com/reference/android/util/SparseArray.html` contains a given `key`. |
| `static boolean` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#contains(android.util.SparseBooleanArray,int)(https://developer.android.com/reference/android/util/SparseBooleanArray.html sparseArray, int key)` Returns whether the given `https://developer.android.com/reference/android/util/SparseBooleanArray.html` contains the given key. |
| `static boolean` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#contains(android.util.SparseIntArray,int)(https://developer.android.com/reference/android/util/SparseIntArray.html sparseArray, int key)` Returns whether the given `https://developer.android.com/reference/android/util/SparseIntArray.html` contains the given key. |
| `static boolean` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi <T> https://developer.android.com/reference/androidx/media3/common/util/Util#contentEquals(android.util.SparseArray<T>,android.util.SparseArray<T>)( @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/util/SparseArray.html<T> sparseArray1, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/util/SparseArray.html<T> sparseArray2 )` Tests two `https://developer.android.com/reference/android/util/SparseArray.html` instances for content equality, handling the case where one or both may be `null`. |
| `static int` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi <T> https://developer.android.com/reference/androidx/media3/common/util/Util#contentHashCode(android.util.SparseArray<T>)(https://developer.android.com/reference/android/util/SparseArray.html<T> sparseArray)` Returns a hash code value for the contents of this `https://developer.android.com/reference/android/util/SparseArray.html`, combining the `https://developer.android.com/reference/java/util/Objects.html#hashCode(java.lang.Object)` result of all its keys and values. |
| `static @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/os/Bundle.html` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CheckReturnValue.html @https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#convertToNullIfInvalid(android.os.Bundle)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/os/Bundle.html bundle)` Converts the provided `https://developer.android.com/reference/android/os/Bundle.html` to `null` if it is invalid. |
| `static int` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#crc16(byte[],int,int,int)(byte[] bytes, int start, int end, int initialValue)` Returns the result of updating a CRC-16 with the specified bytes in a "most significant bit first" order. |
| `static int` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#crc32(byte[],int,int,int)(byte[] bytes, int start, int end, int initialValue)` Returns the result of updating a CRC-32 with the specified bytes in a "most significant bit first" order. |
| `static int` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#crc8(byte[],int,int,int)(byte[] bytes, int start, int end, int initialValue)` Returns the result of updating a CRC-8 with the specified bytes in a "most significant bit first" order. |
| `static https://developer.android.com/reference/android/os/Handler.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#createHandler(android.os.Looper,android.os.Handler.Callback)( https://developer.android.com/reference/android/os/Looper.html looper, @https://developer.android.com/reference/androidx/annotation/Nullable @https://checkerframework.org/api/org/checkerframework/checker/initialization/qual/UnknownInitialization.html https://developer.android.com/reference/android/os/Handler.Callback.html callback )` Creates a `https://developer.android.com/reference/android/os/Handler.html` with the specified `https://developer.android.com/reference/android/os/Handler.Callback.html` on the specified `https://developer.android.com/reference/android/os/Looper.html` thread. |
| `static https://developer.android.com/reference/android/os/Handler.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#createHandlerForCurrentLooper()()` Creates a `https://developer.android.com/reference/android/os/Handler.html` on the current `https://developer.android.com/reference/android/os/Looper.html` thread. |
| `static https://developer.android.com/reference/android/os/Handler.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#createHandlerForCurrentLooper(android.os.Handler.Callback)( @https://developer.android.com/reference/androidx/annotation/Nullable @https://checkerframework.org/api/org/checkerframework/checker/initialization/qual/UnknownInitialization.html https://developer.android.com/reference/android/os/Handler.Callback.html callback )` Creates a `https://developer.android.com/reference/android/os/Handler.html` with the specified `https://developer.android.com/reference/android/os/Handler.Callback.html` on the current `https://developer.android.com/reference/android/os/Looper.html` thread. |
| `static https://developer.android.com/reference/android/os/Handler.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#createHandlerForCurrentOrMainLooper()()` Creates a `https://developer.android.com/reference/android/os/Handler.html` on the current `https://developer.android.com/reference/android/os/Looper.html` thread. |
| `static https://developer.android.com/reference/android/os/Handler.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#createHandlerForCurrentOrMainLooper(android.os.Handler.Callback)( @https://developer.android.com/reference/androidx/annotation/Nullable @https://checkerframework.org/api/org/checkerframework/checker/initialization/qual/UnknownInitialization.html https://developer.android.com/reference/android/os/Handler.Callback.html callback )` Creates a `https://developer.android.com/reference/android/os/Handler.html` with the specified `https://developer.android.com/reference/android/os/Handler.Callback.html` on the current `https://developer.android.com/reference/android/os/Looper.html` thread. |
| `static https://developer.android.com/reference/java/nio/ByteBuffer.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#createReadOnlyByteBuffer(java.nio.ByteBuffer)(https://developer.android.com/reference/java/nio/ByteBuffer.html byteBuffer)` Returns a read-only view of the given `https://developer.android.com/reference/java/nio/ByteBuffer.html`. |
| `static https://developer.android.com/reference/java/io/File.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#createTempDirectory(android.content.Context,java.lang.String)(https://developer.android.com/reference/android/content/Context.html context, https://developer.android.com/reference/java/lang/String.html prefix)` Creates an empty directory in the directory returned by `https://developer.android.com/reference/android/content/Context.html#getCacheDir()`. |
| `static https://developer.android.com/reference/java/io/File.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#createTempFile(android.content.Context,java.lang.String)(https://developer.android.com/reference/android/content/Context.html context, https://developer.android.com/reference/java/lang/String.html prefix)` Creates a new empty file in the directory returned by `https://developer.android.com/reference/android/content/Context.html#getCacheDir()`. |
| `static long` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#durationUsToSampleCount(long,int)(long durationUs, int sampleRate)` Returns the number of samples required to represent `durationUs` of media at ` sampleRate`, assuming all samples are equal duration except the last one which may be shorter. |
| `static void` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#ensureNotificationChannel(android.app.NotificationManager,java.lang.String,java.lang.String)( https://developer.android.com/reference/android/app/NotificationManager.html notificationManager, https://developer.android.com/reference/java/lang/String.html channelId, https://developer.android.com/reference/java/lang/String.html channelName )` Ensure that the `https://developer.android.com/reference/android/app/NotificationChannel.html` with the given channel ID exists. |
| `static https://developer.android.com/reference/java/lang/String.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#escapeFileName(java.lang.String)(https://developer.android.com/reference/java/lang/String.html fileName)` Escapes a string so that it's safe for use as a file or directory name on at least FAT32 filesystems. |
| `static https://developer.android.com/reference/android/net/Uri.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#fixSmoothStreamingIsmManifestUri(android.net.Uri)(https://developer.android.com/reference/android/net/Uri.html uri)` If the provided URI is an ISM Presentation URI, returns the URI with "Manifest" appended to its path (i.e., the corresponding default manifest URI). |
| `static https://developer.android.com/reference/java/lang/String.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#formatInvariant(java.lang.String,java.lang.Object...)(https://developer.android.com/reference/java/lang/String.html format, Object[] args)` Formats a string using `https://developer.android.com/reference/java/util/Locale.html#US`. |
| `static https://developer.android.com/reference/java/lang/String.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#fromUtf8Bytes(byte[])(byte[] bytes)` Returns a new `https://developer.android.com/reference/java/lang/String.html` constructed by decoding UTF-8 encoded bytes. |
| `static https://developer.android.com/reference/java/lang/String.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#fromUtf8Bytes(byte[],int,int)(byte[] bytes, int offset, int length)` Returns a new `https://developer.android.com/reference/java/lang/String.html` constructed by decoding UTF-8 encoded bytes in a subarray. |
| `static int` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#generateAudioSessionId(android.content.Context)(https://developer.android.com/reference/android/content/Context.html context)` Returns a newly generated audio session identifier, or `https://developer.android.com/reference/androidx/media3/common/C#AUDIO_SESSION_ID_UNSET()` if failed to generate an identifier and in which case audio playback may fail. |
| `static int` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi @https://checkerframework.org/api/com/google/errorprone/annotations/InlineMe.html(replacement = "Util.generateAudioSessionId(context)", imports = "androidx.media3.common.util.Util") [generateAudioSessionIdV21](https://developer.android.com/reference/androidx/media3/common/util/Util#generateAudioSessionIdV21(android.content.Context))(https://developer.android.com/reference/android/content/Context.html context)` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/media3/common/util/Util#generateAudioSessionId(android.content.Context)` instead. <br /> |
| `static @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/media3/common/util/Util#getAdaptiveMimeTypeForContentType(int)(@https://developer.android.com/reference/androidx/media3/common/C.ContentType int contentType)` Returns the MIME type corresponding to the given adaptive `https://developer.android.com/reference/androidx/media3/common/C.ContentType`, or `null` if the content type is not adaptive. |
| `static int` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#getApiLevelThatAudioFormatIntroducedAudioEncoding(int)(int encoding)` Retrieves the API Level that `https://developer.android.com/reference/android/media/AudioFormat.html` introduced an encoding. |
| `static int` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi @https://developer.android.com/reference/androidx/media3/common/C.AudioContentType [getAudioContentTypeForStreamType](https://developer.android.com/reference/androidx/media3/common/util/Util#getAudioContentTypeForStreamType(int))(@https://developer.android.com/reference/androidx/media3/common/C.StreamType int streamType)` **This method is deprecated.** This method is no longer used by the media3 library, it does not work well and should be avoided. <br /> |
| `static https://developer.android.com/reference/android/media/AudioFormat.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#getAudioFormat(int,int,int)(int sampleRate, int channelConfig, int encoding)` Creates `https://developer.android.com/reference/android/media/AudioFormat.html` with given sampleRate, channelConfig, and encoding. |
| `static int` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#getAudioTrackChannelConfig(int)(int channelCount)` Returns the audio track channel configuration for the given channel count, or `https://developer.android.com/reference/android/media/AudioFormat.html#CHANNEL_INVALID` if output is not possible. |
| `static int` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#getAudioTrackChannelConfig(androidx.media3.common.Format)(https://developer.android.com/reference/androidx/media3/common/Format format)` Returns the audio track channel configuration for the given `https://developer.android.com/reference/androidx/media3/common/Format`, or `https://developer.android.com/reference/android/media/AudioFormat.html#CHANNEL_INVALID` if output is not possible. |
| `static int` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi @https://developer.android.com/reference/androidx/media3/common/C.AudioUsage https://developer.android.com/reference/androidx/media3/common/util/Util#getAudioUsageForStreamType(int)(@https://developer.android.com/reference/androidx/media3/common/C.StreamType int streamType)` Returns the `https://developer.android.com/reference/androidx/media3/common/C.AudioUsage` corresponding to the specified `https://developer.android.com/reference/androidx/media3/common/C.StreamType`. |
| `static https://developer.android.com/reference/java/lang/String.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#getAuxiliaryTrackTypeString(int)( @https://developer.android.com/reference/androidx/media3/common/C.AuxiliaryTrackType int auxiliaryTrackType )` Returns a string representation of the `https://developer.android.com/reference/androidx/media3/common/C.AuxiliaryTrackType`. |
| `static https://developer.android.com/reference/androidx/media3/common/Player.Commands` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#getAvailableCommands(androidx.media3.common.Player,androidx.media3.common.Player.Commands)( https://developer.android.com/reference/androidx/media3/common/Player player, https://developer.android.com/reference/androidx/media3/common/Player.Commands permanentAvailableCommands )` Returns the `https://developer.android.com/reference/androidx/media3/common/Player.Commands` available in the `https://developer.android.com/reference/androidx/media3/common/Player`. |
| `static int` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#getBigEndianInt(java.nio.ByteBuffer,int)(https://developer.android.com/reference/java/nio/ByteBuffer.html buffer, int index)` Absolute *get* method for reading an int value in `https://developer.android.com/reference/java/nio/ByteOrder.html#BIG_ENDIAN` in a `https://developer.android.com/reference/java/nio/ByteBuffer.html`. |
| `static int` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi @https://developer.android.com/reference/androidx/media3/common/C.BufferFlags https://developer.android.com/reference/androidx/media3/common/util/Util#getBufferFlagsFromMediaCodecFlags(int)(int mediaCodecFlags)` Returns `https://developer.android.com/reference/androidx/media3/common/C.BufferFlags` corresponding to `https://developer.android.com/reference/android/media/MediaCodec.html` flags. |
| `static int` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#getByteDepth(int)(@https://developer.android.com/reference/androidx/media3/common/C.PcmEncoding int pcmEncoding)` Returns the byte depth for audio with the specified encoding. |
| `static byte[]` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#getBytesFromHexString(java.lang.String)(https://developer.android.com/reference/java/lang/String.html hexString)` Returns a byte array containing values parsed from the hex string provided. |
| `static int` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#getCodecCountOfType(java.lang.String,int)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html codecs, @https://developer.android.com/reference/androidx/media3/common/C.TrackType int trackType)` Returns the number of codec strings in `codecs` whose type matches `trackType`. |
| `static @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#getCodecsOfType(java.lang.String,int)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html codecs, @https://developer.android.com/reference/androidx/media3/common/C.TrackType int trackType)` Returns a copy of `codecs` without the codecs whose track type doesn't match ` trackType`. |
| `static @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#getCodecsWithoutType(java.lang.String,int)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html codecs, @https://developer.android.com/reference/androidx/media3/common/C.TrackType int trackType)` Returns a copy of `codecs` without the codecs whose track type matches `trackType`. |
| `static @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/ColorInfo` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#getColorInfoForDolbyVision(java.lang.String,java.lang.String,java.lang.String)( @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html codecs, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html supplementalCodecs, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html supplementalProfiles )` Returns the `https://developer.android.com/reference/androidx/media3/common/ColorInfo` for specific Dolby Vision codecs and profiles. |
| `static https://developer.android.com/reference/java/lang/String.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#getCountryCode(android.content.Context)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/content/Context.html context)` Returns the upper-case ISO 3166-1 alpha-2 country code of the current registered operator's MCC (Mobile Country Code), or the country code of the default Locale if not available. |
| `static https://developer.android.com/reference/android/graphics/Point.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#getCurrentDisplayModeSize(android.content.Context)(https://developer.android.com/reference/android/content/Context.html context)` Gets the size of the current mode of the default display, in pixels. |
| `static https://developer.android.com/reference/android/graphics/Point.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#getCurrentDisplayModeSize(android.content.Context,android.view.Display)(https://developer.android.com/reference/android/content/Context.html context, https://developer.android.com/reference/android/view/Display.html display)` Gets the size of the current mode of the specified display, in pixels. |
| `static https://developer.android.com/reference/android/os/Looper.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#getCurrentOrMainLooper()()` Returns the `https://developer.android.com/reference/android/os/Looper.html` associated with the current thread, or the `https://developer.android.com/reference/android/os/Looper.html` of the application's main thread if the current thread doesn't have a `https://developer.android.com/reference/android/os/Looper.html`. |
| `static https://developer.android.com/reference/android/net/Uri.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#getDataUriForString(java.lang.String,java.lang.String)(https://developer.android.com/reference/java/lang/String.html mimeType, https://developer.android.com/reference/java/lang/String.html data)` Returns a data URI with the specified MIME type and data. |
| `static https://developer.android.com/reference/java/util/Locale.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi @https://checkerframework.org/api/com/google/errorprone/annotations/InlineMe.html(replacement = "Locale.getDefault(Locale.Category.DISPLAY)", imports = [""java.util.Locale""]) [getDefaultDisplayLocale](https://developer.android.com/reference/androidx/media3/common/util/Util#getDefaultDisplayLocale())()` **This method is deprecated.** Use `https://developer.android.com/reference/java/util/Locale.html#getDefault(java.util.Locale.Category)` with `https://developer.android.com/reference/java/util/Locale.Category.html#DISPLAY` instead. <br /> |
| `static https://developer.android.com/reference/android/graphics/drawable/Drawable.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#getDrawable(android.content.Context,android.content.res.Resources,int)( https://developer.android.com/reference/android/content/Context.html context, https://developer.android.com/reference/android/content/res/Resources.html resources, @https://developer.android.com/reference/androidx/annotation/DrawableRes int drawableRes )` Returns a `https://developer.android.com/reference/android/graphics/drawable/Drawable.html` for the given resource or throws a `https://developer.android.com/reference/android/content/res/Resources.NotFoundException.html` if not found. |
| `static @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/util/UUID.html` | `https://developer.android.com/reference/androidx/media3/common/util/Util#getDrmUuid(java.lang.String)(https://developer.android.com/reference/java/lang/String.html drmScheme)` Derives a DRM `https://developer.android.com/reference/java/util/UUID.html` from `drmScheme`. |
| `static https://developer.android.com/reference/java/lang/String.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#getEncodingString(int)(@https://developer.android.com/reference/androidx/media3/common/C.Encoding int encoding)` Returns a user-readable string representation of the given `https://developer.android.com/reference/androidx/media3/common/C.Encoding`. |
| `static int` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi @https://developer.android.com/reference/androidx/media3/common/PlaybackException.ErrorCode https://developer.android.com/reference/androidx/media3/common/util/Util#getErrorCodeForMediaDrmErrorCode(int)(int mediaDrmErrorCode)` Returns a `https://developer.android.com/reference/androidx/media3/common/PlaybackException.ErrorCode` value that corresponds to the provided `https://developer.android.com/reference/android/media/MediaDrm.ErrorCodes.html` value. |
| `static int` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#getErrorCodeFromPlatformDiagnosticsInfo(java.lang.String)( @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html diagnosticsInfo )` Attempts to parse an error code from a diagnostic string found in framework media exceptions. |
| `static int` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi @https://developer.android.com/reference/androidx/media3/common/C.PcmEncoding https://developer.android.com/reference/androidx/media3/common/util/Util#getFloatPcmEncoding(int)(int bitDepth)` Converts a sample bit depth to a corresponding little-endian float PCM encoding constant. |
| `static int` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi @https://developer.android.com/reference/androidx/media3/common/C.PcmEncoding https://developer.android.com/reference/androidx/media3/common/util/Util#getFloatPcmEncoding(int,java.nio.ByteOrder)(int bitDepth, https://developer.android.com/reference/java/nio/ByteOrder.html byteOrder)` Converts a sample bit depth and byte order to a corresponding float PCM encoding constant. |
| `static https://developer.android.com/reference/java/lang/String.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#getFormatSupportString(int)(@https://developer.android.com/reference/androidx/media3/common/C.FormatSupport int formatSupport)` Returns string representation of a `https://developer.android.com/reference/androidx/media3/common/C.FormatSupport` flag. |
| `static int` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#getInt24(java.nio.ByteBuffer,int)(https://developer.android.com/reference/java/nio/ByteBuffer.html buffer, int index)` Returns the sign-extended 24-bit integer value at `index`. |
| `static int` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#getIntegerCodeForString(java.lang.String)(https://developer.android.com/reference/java/lang/String.html string)` Returns the integer equal to the big-endian concatenation of the characters in `string` as bytes. |
| `static https://developer.android.com/reference/java/lang/String.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi @https://checkerframework.org/api/com/google/errorprone/annotations/InlineMe.html(replacement = "locale.toLanguageTag()") [getLocaleLanguageTag](https://developer.android.com/reference/androidx/media3/common/util/Util#getLocaleLanguageTag(java.util.Locale))(https://developer.android.com/reference/java/util/Locale.html locale)` **This method is deprecated.** Use `https://developer.android.com/reference/java/util/Locale.html#toLanguageTag()` instead. <br /> |
| `static int` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#getMaxPendingFramesCountForMediaCodecDecoders(android.content.Context)(https://developer.android.com/reference/android/content/Context.html context)` Returns the number of maximum pending output frames that are allowed on a `https://developer.android.com/reference/android/media/MediaCodec.html` decoder. |
| `static long` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#getMediaDurationForPlayoutDuration(long,float)(long playoutDuration, float speed)` Returns the duration of media that will elapse in `playoutDuration`. |
| `static long` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#getNowUnixTimeMs(long)(long elapsedRealtimeEpochOffsetMs)` Returns the current time in milliseconds since the epoch. |
| `static int` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi @https://developer.android.com/reference/androidx/media3/common/C.PcmEncoding https://developer.android.com/reference/androidx/media3/common/util/Util#getPcmEncoding(int)(int bitDepth)` Converts a sample bit depth to a corresponding little-endian integer PCM encoding constant. |
| `static int` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi @https://developer.android.com/reference/androidx/media3/common/C.PcmEncoding https://developer.android.com/reference/androidx/media3/common/util/Util#getPcmEncoding(int,java.nio.ByteOrder)(int bitDepth, https://developer.android.com/reference/java/nio/ByteOrder.html byteOrder)` Converts a sample bit depth and byte order to a corresponding integer PCM encoding constant. |
| `static https://developer.android.com/reference/androidx/media3/common/Format` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#getPcmFormat(androidx.media3.common.audio.AudioProcessor.AudioFormat)(https://developer.android.com/reference/androidx/media3/common/audio/AudioProcessor.AudioFormat audioFormat)` Gets a PCM `https://developer.android.com/reference/androidx/media3/common/Format` based on the `https://developer.android.com/reference/androidx/media3/common/audio/AudioProcessor.AudioFormat`. |
| `static https://developer.android.com/reference/androidx/media3/common/Format` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#getPcmFormat(int,int,int)(@https://developer.android.com/reference/androidx/media3/common/C.PcmEncoding int pcmEncoding, int channels, int sampleRate)` Gets a PCM `https://developer.android.com/reference/androidx/media3/common/Format` with the specified parameters. |
| `static int` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi @https://checkerframework.org/api/org/checkerframework/dataflow/qual/Pure.html https://developer.android.com/reference/androidx/media3/common/util/Util#getPcmFrameSize(int,int)(@https://developer.android.com/reference/androidx/media3/common/C.PcmEncoding int pcmEncoding, int channelCount)` Returns the frame size for audio with `channelCount` channels in the specified encoding. |
| `static long` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#getPlayoutDurationForMediaDuration(long,float)(long mediaDuration, float speed)` Returns the playout duration of `mediaDuration` of media. |
| `static https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/java/lang/String.html>` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#getRoleFlagStrings(int)(@https://developer.android.com/reference/androidx/media3/common/C.RoleFlags int roleFlags)` Returns a list of strings representing the `https://developer.android.com/reference/androidx/media3/common/C.RoleFlags` values present in ` roleFlags`. |
| `static https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/java/lang/String.html>` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#getSelectionFlagStrings(int)(@https://developer.android.com/reference/androidx/media3/common/C.SelectionFlags int selectionFlags)` Returns a list of strings representing the `https://developer.android.com/reference/androidx/media3/common/C.SelectionFlags` values present in ` selectionFlags`. |
| `static int` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi @https://developer.android.com/reference/androidx/media3/common/C.StreamType [getStreamTypeForAudioUsage](https://developer.android.com/reference/androidx/media3/common/util/Util#getStreamTypeForAudioUsage(int))(@https://developer.android.com/reference/androidx/media3/common/C.AudioUsage int usage)` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/media3/common/AudioAttributes#getStreamType()` instead. <br /> |
| `static https://developer.android.com/reference/java/lang/String.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#getStringForTime(long)(long timeMs)` Returns the specified millisecond time formatted as a string. |
| `static https://developer.android.com/reference/java/lang/String.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#getStringForTime(java.lang.StringBuilder,java.util.Formatter,long)( https://developer.android.com/reference/java/lang/StringBuilder.html builder, https://developer.android.com/reference/java/util/Formatter.html formatter, long timeMs )` Returns the specified millisecond time formatted as a string. |
| `static String[]` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#getSystemLanguageCodes()()` Returns a non-empty array of normalized IETF BCP 47 language tags for the system languages ordered by preference. |
| `static @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#getSystemProperty(java.lang.String)(https://developer.android.com/reference/java/lang/String.html name)` Returns the value of the given system property, or `null` if the property cannot be read or is not set. |
| `static https://developer.android.com/reference/java/lang/String.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#getTrackTypeString(int)(@https://developer.android.com/reference/androidx/media3/common/C.TrackType int trackType)` Returns a string representation of a `https://developer.android.com/reference/androidx/media3/common/C.TrackType`. |
| `static https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/media3/common/util/Util#getUserAgent(android.content.Context,java.lang.String)(https://developer.android.com/reference/android/content/Context.html context, https://developer.android.com/reference/java/lang/String.html applicationName)` Returns a user agent string based on the given application name and the library version. |
| `static byte[]` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#getUtf8Bytes(java.lang.String)(https://developer.android.com/reference/java/lang/String.html value)` Returns a new byte array containing the code points of a `https://developer.android.com/reference/java/lang/String.html` encoded using UTF-8. |
| `static int` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi @https://developer.android.com/reference/androidx/media3/common/C.VideoCodecFlags https://developer.android.com/reference/androidx/media3/common/util/Util#getVideoCodecFlagForMime(java.lang.String)(https://developer.android.com/reference/java/lang/String.html mimeType)` Returns the `https://developer.android.com/reference/androidx/media3/common/C.VideoCodecFlags` corresponding to the provided MIME type. |
| `static byte[]` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#gzip(byte[])(byte[] input)` Compresses `input` using gzip and returns the result in a newly allocated byte array. |
| `static boolean` | `https://developer.android.com/reference/androidx/media3/common/util/Util#handlePauseButtonAction(androidx.media3.common.Player)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/Player player)` Updates the player to handle an interaction with a pause button. |
| `static boolean` | `https://developer.android.com/reference/androidx/media3/common/util/Util#handlePlayButtonAction(androidx.media3.common.Player)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/Player player)` Updates the player to handle an interaction with a play button. |
| `static boolean` | `https://developer.android.com/reference/androidx/media3/common/util/Util#handlePlayPauseButtonAction(androidx.media3.common.Player)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/Player player)` Updates the player to handle an interaction with a play or pause button. |
| `static boolean` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#handlePlayPauseButtonAction(androidx.media3.common.Player,boolean)( @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/Player player, boolean playIfSuppressed )` Updates the player to handle an interaction with a play or pause button. |
| `static void` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi <T> https://developer.android.com/reference/androidx/media3/common/util/Util#ignoreFuture(java.util.concurrent.Future<T>)(https://developer.android.com/reference/java/util/concurrent/Future.html<T> unused)` Ignores the future to avoid static code analysis tools to complain. |
| `static int` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi @https://developer.android.com/reference/androidx/media3/common/C.ContentType [inferContentType](https://developer.android.com/reference/androidx/media3/common/util/Util#inferContentType(java.lang.String))(https://developer.android.com/reference/java/lang/String.html fileName)` **This method is deprecated.** Use `https://developer.android.com/reference/android/net/Uri.html#parse(java.lang.String)` and `https://developer.android.com/reference/androidx/media3/common/util/Util#inferContentType(android.net.Uri)` for full file paths or `https://developer.android.com/reference/androidx/media3/common/util/Util#inferContentTypeForExtension(java.lang.String)` for extensions. <br /> |
| `static int` | `@https://developer.android.com/reference/androidx/media3/common/C.ContentType https://developer.android.com/reference/androidx/media3/common/util/Util#inferContentType(android.net.Uri)(https://developer.android.com/reference/android/net/Uri.html uri)` Makes a best guess to infer the `https://developer.android.com/reference/androidx/media3/common/C.ContentType` from a `https://developer.android.com/reference/android/net/Uri.html`. |
| `static int` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi @https://developer.android.com/reference/androidx/media3/common/C.ContentType [inferContentType](https://developer.android.com/reference/androidx/media3/common/util/Util#inferContentType(android.net.Uri,java.lang.String))(https://developer.android.com/reference/android/net/Uri.html uri, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html overrideExtension)` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/media3/common/util/Util#inferContentTypeForExtension(java.lang.String)` when `overrideExtension` is non-empty, and `https://developer.android.com/reference/androidx/media3/common/util/Util#inferContentType(android.net.Uri)` otherwise. <br /> |
| `static int` | `@https://developer.android.com/reference/androidx/media3/common/C.ContentType https://developer.android.com/reference/androidx/media3/common/util/Util#inferContentTypeForExtension(java.lang.String)(https://developer.android.com/reference/java/lang/String.html fileExtension)` Makes a best guess to infer the `https://developer.android.com/reference/androidx/media3/common/C.ContentType` from a file extension. |
| `static int` | `@https://developer.android.com/reference/androidx/media3/common/C.ContentType https://developer.android.com/reference/androidx/media3/common/util/Util#inferContentTypeForUriAndMimeType(android.net.Uri,java.lang.String)(https://developer.android.com/reference/android/net/Uri.html uri, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html mimeType)` Makes a best guess to infer the `https://developer.android.com/reference/androidx/media3/common/C.ContentType` from a `https://developer.android.com/reference/android/net/Uri.html` and optional MIME type. |
| `static boolean` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#inflate(androidx.media3.common.util.ParsableByteArray,androidx.media3.common.util.ParsableByteArray,java.util.zip.Inflater)( https://developer.android.com/reference/androidx/media3/common/util/ParsableByteArray input, https://developer.android.com/reference/androidx/media3/common/util/ParsableByteArray output, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/util/zip/Inflater.html inflater )` Uncompresses the data in `input`. |
| `static https://developer.android.com/reference/java/lang/String.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#intToStringMaxRadix(int)(int i)` Returns a string representation of the integer using radix value `https://developer.android.com/reference/java/lang/Character.html#MAX_RADIX`. |
| `static boolean` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#isAutomotive(android.content.Context)(https://developer.android.com/reference/android/content/Context.html context)` Returns whether the app is running on an automotive device. |
| `static boolean` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#isBitmapFactorySupportedMimeType(java.lang.String)(https://developer.android.com/reference/java/lang/String.html mimeType)` Returns the image MIME types that can be decoded and loaded by `https://developer.android.com/reference/android/graphics/BitmapFactory.html` that Media3 aims to support. |
| `static boolean` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#isEncodingHighResolutionPcm(int)(@https://developer.android.com/reference/androidx/media3/common/C.PcmEncoding int encoding)` Returns whether `encoding` is high resolution (\> 16-bit) PCM. |
| `static boolean` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#isEncodingLinearPcm(int)(@https://developer.android.com/reference/androidx/media3/common/C.Encoding int encoding)` Returns whether `encoding` is one of the linear PCM encodings. |
| `static boolean` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#isFloatPcmEncoding(int)(@https://developer.android.com/reference/androidx/media3/common/C.PcmEncoding int encoding)` Returns whether `encoding` is a floating-point PCM encoding. |
| `static boolean` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#isFrameDropAllowedOnSurfaceInput(android.content.Context)(https://developer.android.com/reference/android/content/Context.html context)` |
| `static boolean` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#isLinebreak(int)(int c)` Returns whether the given character is a carriage return ('\\r') or a line feed ('\\n'). |
| `static boolean` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#isLocalFileUri(android.net.Uri)(https://developer.android.com/reference/android/net/Uri.html uri)` Returns true if the URI is a path to a local file or a reference to a local file. |
| `static boolean` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#isPcmEncodingBigEndian(int)(@https://developer.android.com/reference/androidx/media3/common/C.PcmEncoding int encoding)` Returns whether `encoding` is a big-endian PCM encoding. |
| `static boolean` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#isRunningOnEmulator()()` Returns true if the code path is currently running on an emulator. |
| `static boolean` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#isSorted(long[])(long[] values)` Returns whether `values` is sorted in ascending order. |
| `static boolean` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#isTv(android.content.Context)(https://developer.android.com/reference/android/content/Context.html context)` Returns whether the app is running on a TV device. |
| `static boolean` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#isWear(android.content.Context)(https://developer.android.com/reference/android/content/Context.html context)` Returns whether the app is running on a Wear OS device. |
| `static int` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#linearSearch(int[],int)(int[] array, int value)` Returns the index of the first occurrence of `value` in `array`, or `https://developer.android.com/reference/androidx/media3/common/C#INDEX_UNSET()` if `value` is not contained in `array`. |
| `static int` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#linearSearch(long[],long)(long[] array, long value)` Returns the index of the first occurrence of `value` in `array`, or `https://developer.android.com/reference/androidx/media3/common/C#INDEX_UNSET()` if `value` is not contained in `array`. |
| `static https://developer.android.com/reference/java/lang/String.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#loadAsset(android.content.Context,java.lang.String)(https://developer.android.com/reference/android/content/Context.html context, https://developer.android.com/reference/java/lang/String.html assetPath)` Loads a file from the assets folder. |
| `static https://developer.android.com/reference/java/lang/String.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#loadRawResource(android.content.Context,int)(https://developer.android.com/reference/android/content/Context.html context, int resId)` Loads a file from a raw resource. |
| `static long` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#maxValue(android.util.SparseLongArray)(https://developer.android.com/reference/android/util/SparseLongArray.html sparseLongArray)` Returns the maximum value in the given `https://developer.android.com/reference/android/util/SparseLongArray.html`. |
| `static boolean` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#maybeInflate(androidx.media3.common.util.ParsableByteArray,androidx.media3.common.util.ParsableByteArray,java.util.zip.Inflater)( https://developer.android.com/reference/androidx/media3/common/util/ParsableByteArray input, https://developer.android.com/reference/androidx/media3/common/util/ParsableByteArray output, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/util/zip/Inflater.html inflater )` Uncompresses the data in `input` if it starts with the zlib marker `0x78`. |
| `static boolean` | `[maybeRequestReadExternalStoragePermission](https://developer.android.com/reference/androidx/media3/common/util/Util#maybeRequestReadExternalStoragePermission(android.app.Activity,androidx.media3.common.MediaItem...))( https://developer.android.com/reference/android/app/Activity.html activity, MediaItem[] mediaItems )` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/media3/common/util/Util#maybeRequestReadStoragePermission(android.app.Activity,androidx.media3.common.MediaItem...)` instead. <br /> |
| `static boolean` | `[maybeRequestReadExternalStoragePermission](https://developer.android.com/reference/androidx/media3/common/util/Util#maybeRequestReadExternalStoragePermission(android.app.Activity,android.net.Uri...))( https://developer.android.com/reference/android/app/Activity.html activity, Uri[] uris )` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/media3/common/util/Util#maybeRequestReadStoragePermission(android.app.Activity,androidx.media3.common.MediaItem...)` instead. <br /> |
| `static boolean` | `https://developer.android.com/reference/androidx/media3/common/util/Util#maybeRequestReadStoragePermission(android.app.Activity,androidx.media3.common.MediaItem...)( https://developer.android.com/reference/android/app/Activity.html activity, MediaItem[] mediaItems )` Checks whether it's necessary to request storage reading permissions for the specified `https://developer.android.com/reference/androidx/media3/common/MediaItem`, requesting the permissions if necessary. |
| `static long` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#minValue(android.util.SparseLongArray)(https://developer.android.com/reference/android/util/SparseLongArray.html sparseLongArray)` Returns the minimum value in the given `https://developer.android.com/reference/android/util/SparseLongArray.html`. |
| `static void` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi <T extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/media3/common/util/Util#moveItems(java.util.List<T>,int,int,int)( https://developer.android.com/reference/java/util/List.html<T> items, int fromIndex, int toIndex, int newFromIndex )` Moves the elements starting at `fromIndex` to `newFromIndex`. |
| `static long` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#msToUs(long)(long timeMs)` Converts a time in milliseconds to the corresponding time in microseconds, preserving `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` values and `https://developer.android.com/reference/androidx/media3/common/C#TIME_END_OF_SOURCE()` values. |
| `static https://developer.android.com/reference/java/util/concurrent/ExecutorService.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#newSingleThreadExecutor(java.lang.String)(https://developer.android.com/reference/java/lang/String.html threadName)` Instantiates a new single threaded executor whose thread has the specified name. |
| `static https://developer.android.com/reference/java/util/concurrent/ScheduledExecutorService.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#newSingleThreadScheduledExecutor(java.lang.String)(https://developer.android.com/reference/java/lang/String.html threadName)` Instantiates a new single threaded scheduled executor whose thread has the specified name. |
| `static @https://checkerframework.org/api/org/checkerframework/checker/nullness/qual/PolyNull.html https://developer.android.com/reference/java/lang/String.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi @https://checkerframework.org/api/org/checkerframework/checker/nullness/qual/PolyNull.html https://developer.android.com/reference/androidx/media3/common/util/Util#normalizeLanguageCode(java.lang.String)(@https://checkerframework.org/api/org/checkerframework/checker/nullness/qual/PolyNull.html @https://checkerframework.org/api/org/checkerframework/checker/nullness/qual/PolyNull.html https://developer.android.com/reference/java/lang/String.html language)` Returns a normalized IETF BCP 47 language tag for `language`. |
| `static long` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#nsToMs(long)(long timeNs)` Converts a time in nanoseconds to the corresponding time in milliseconds, preserving `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` and `https://developer.android.com/reference/androidx/media3/common/C#TIME_END_OF_SOURCE()` values. |
| `static T[]` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi <T> https://developer.android.com/reference/androidx/media3/common/util/Util#nullSafeArrayAppend(T[],T)(T[] original, T newElement)` Creates a new array containing `original` with `newElement` appended. |
| `static T[]` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi <T> https://developer.android.com/reference/androidx/media3/common/util/Util#nullSafeArrayConcatenation(T[],T[])(T[] first, T[] second)` Creates a new array containing the concatenation of two non-null type arrays. |
| `static T[]` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi <T> https://developer.android.com/reference/androidx/media3/common/util/Util#nullSafeArrayCopy(T[],int)(T[] input, int length)` Copies and optionally truncates an array. |
| `static T[]` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi <T> https://developer.android.com/reference/androidx/media3/common/util/Util#nullSafeArrayCopyOfRange(T[],int,int)(T[] input, int from, int to)` Copies a subset of an array. |
| `static void` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi <T> https://developer.android.com/reference/androidx/media3/common/util/Util#nullSafeListToArray(java.util.List<T>,T[])(https://developer.android.com/reference/java/util/List.html<T> list, T[] array)` Copies the contents of `list` into `array`. |
| `static long` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#parseXsDateTime(java.lang.String)(https://developer.android.com/reference/java/lang/String.html value)` Parses an xs:dateTime attribute value, returning the parsed timestamp in milliseconds since the epoch. |
| `static long` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#parseXsDuration(java.lang.String)(https://developer.android.com/reference/java/lang/String.html value)` Parses an xs:duration attribute value, returning the parsed duration in milliseconds. |
| `static float` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#percentFloat(long,long)(long numerator, long denominator)` Returns the floating point percentage of `numerator` divided by `denominator`. |
| `static int` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#percentInt(long,long)(long numerator, long denominator)` Returns the integer percentage of `numerator` divided by `denominator`. |
| `static boolean` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#postOrRun(android.os.Handler,java.lang.Runnable)(https://developer.android.com/reference/android/os/Handler.html handler, https://developer.android.com/reference/java/lang/Runnable.html runnable)` Posts the `https://developer.android.com/reference/java/lang/Runnable.html` if the calling thread differs with the `https://developer.android.com/reference/android/os/Looper.html` of the `https://developer.android.com/reference/android/os/Handler.html`. |
| `static boolean` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#postOrRun(androidx.media3.common.util.HandlerWrapper,java.lang.Runnable)(https://developer.android.com/reference/androidx/media3/common/util/HandlerWrapper handler, https://developer.android.com/reference/java/lang/Runnable.html runnable)` Posts the `https://developer.android.com/reference/java/lang/Runnable.html` if the calling thread differs with the `https://developer.android.com/reference/android/os/Looper.html` of the `https://developer.android.com/reference/androidx/media3/common/util/HandlerWrapper`. |
| `static https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<T>` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi <T> https://developer.android.com/reference/androidx/media3/common/util/Util#postOrRunWithCompletion(android.os.Handler,java.lang.Runnable,T)( https://developer.android.com/reference/android/os/Handler.html handler, https://developer.android.com/reference/java/lang/Runnable.html runnable, T successValue )` Posts the `https://developer.android.com/reference/java/lang/Runnable.html` if the calling thread differs with the `https://developer.android.com/reference/android/os/Looper.html` of the `https://developer.android.com/reference/android/os/Handler.html`. |
| `static void` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#putInt24(java.nio.ByteBuffer,int)(https://developer.android.com/reference/java/nio/ByteBuffer.html buffer, int value)` Writes a 24-bit integer value to a buffer at its current `https://developer.android.com/reference/java/nio/Buffer.html#position()`. |
| `static boolean` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#readBoolean(android.os.Parcel)(https://developer.android.com/reference/android/os/Parcel.html parcel)` Reads an integer from a `https://developer.android.com/reference/android/os/Parcel.html` and interprets it as a boolean, with 0 mapping to false and all other values mapping to true. |
| `static void` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#recursiveDelete(java.io.File)(https://developer.android.com/reference/java/io/File.html fileOrDirectory)` Recursively deletes a directory and its content. |
| `static @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/content/Intent.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#registerReceiverNotExported(android.content.Context,android.content.BroadcastReceiver,android.content.IntentFilter)( https://developer.android.com/reference/android/content/Context.html context, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/content/BroadcastReceiver.html receiver, https://developer.android.com/reference/android/content/IntentFilter.html filter )` Registers a `https://developer.android.com/reference/android/content/BroadcastReceiver.html` that's not intended to receive broadcasts from other apps. |
| `static void` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi <T> https://developer.android.com/reference/androidx/media3/common/util/Util#removeRange(java.util.List<T>,int,int)(https://developer.android.com/reference/java/util/List.html<T> list, int fromIndex, int toIndex)` Removes an indexed range from a List. |
| `static long` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi @https://checkerframework.org/api/org/checkerframework/dataflow/qual/Pure.html https://developer.android.com/reference/androidx/media3/common/util/Util#sampleCountToDurationUs(long,int)(long sampleCount, int sampleRate)` Returns the total duration (in microseconds) of `sampleCount` samples of equal duration at `sampleRate`. |
| `static long` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#scaleLargeTimestamp(long,long,long)(long timestamp, long multiplier, long divisor)` Scales a large timestamp. |
| `static long[]` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#scaleLargeTimestamps(java.util.List<java.lang.Long>,long,long)( https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/java/lang/Long.html> timestamps, long multiplier, long divisor )` Applies `https://developer.android.com/reference/androidx/media3/common/util/Util#scaleLargeTimestamp(long,long,long)` to a list of unscaled timestamps. |
| `static void` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#scaleLargeTimestampsInPlace(long[],long,long)( long[] timestamps, long multiplier, long divisor )` Applies `https://developer.android.com/reference/androidx/media3/common/util/Util#scaleLargeTimestamp(long,long,long)` to an array of unscaled timestamps. |
| `static long` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#scaleLargeValue(long,long,long,java.math.RoundingMode)( long value, long multiplier, long divisor, https://developer.android.com/reference/java/math/RoundingMode.html roundingMode )` Scales a large value by a multiplier and a divisor. |
| `static long[]` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#scaleLargeValues(java.util.List<java.lang.Long>,long,long,java.math.RoundingMode)( https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/java/lang/Long.html> values, long multiplier, long divisor, https://developer.android.com/reference/java/math/RoundingMode.html roundingMode )` Applies `https://developer.android.com/reference/androidx/media3/common/util/Util#scaleLargeValue(long,long,long,java.math.RoundingMode)` to a list of unscaled values. |
| `static void` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#scaleLargeValuesInPlace(long[],long,long,java.math.RoundingMode)( long[] values, long multiplier, long divisor, https://developer.android.com/reference/java/math/RoundingMode.html roundingMode )` Applies `https://developer.android.com/reference/androidx/media3/common/util/Util#scaleLargeValue(long,long,long,java.math.RoundingMode)` to an array of unscaled values. |
| `static void` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#setForegroundServiceNotification(android.app.Service,int,android.app.Notification,int,java.lang.String)( https://developer.android.com/reference/android/app/Service.html service, int notificationId, https://developer.android.com/reference/android/app/Notification.html notification, int foregroundServiceType, https://developer.android.com/reference/java/lang/String.html foregroundServiceManifestType )` Sets the notification required for a foreground service. |
| `static boolean` | `@https://checkerframework.org/api/org/checkerframework/checker/nullness/qual/EnsuresNonNullIf.html(result = true, expression = "#1") @https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#shouldEnablePlayPauseButton(androidx.media3.common.Player)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/Player player)` Returns whether a play-pause button should be enabled or not. |
| `static boolean` | `@https://checkerframework.org/api/org/checkerframework/checker/nullness/qual/EnsuresNonNullIf.html(result = false, expression = "#1") https://developer.android.com/reference/androidx/media3/common/util/Util#shouldShowPlayButton(androidx.media3.common.Player)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/Player player)` Returns whether a play button should be presented on a UI element for playback control. |
| `static boolean` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi @https://checkerframework.org/api/org/checkerframework/checker/nullness/qual/EnsuresNonNullIf.html(result = false, expression = "#1") https://developer.android.com/reference/androidx/media3/common/util/Util#shouldShowPlayButton(androidx.media3.common.Player,boolean)( @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/Player player, boolean shouldShowPlayIfSuppressed )` Returns whether a play button should be presented on a UI element for playback control. |
| `static void` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#sneakyThrow(java.lang.Throwable)(https://developer.android.com/reference/java/lang/Throwable.html t)` A hacky method that always throws `t` even if `t` is a checked exception, and is not declared to be thrown. |
| `static String[]` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#split(java.lang.String,java.lang.String)(https://developer.android.com/reference/java/lang/String.html value, https://developer.android.com/reference/java/lang/String.html regex)` Splits a string using `value.split(regex, -1`). |
| `static String[]` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#splitAtFirst(java.lang.String,java.lang.String)(https://developer.android.com/reference/java/lang/String.html value, https://developer.android.com/reference/java/lang/String.html regex)` Splits the string at the first occurrence of the delimiter `regex`. |
| `static String[]` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#splitCodecs(java.lang.String)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html codecs)` Splits a codecs sequence string, as defined in RFC 6381, into individual codec strings. |
| `static @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/content/ComponentName.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#startForegroundService(android.content.Context,android.content.Intent)(https://developer.android.com/reference/android/content/Context.html context, https://developer.android.com/reference/android/content/Intent.html intent)` Calls `https://developer.android.com/reference/android/content/Context.html#startForegroundService(android.content.Intent)` if `https://developer.android.com/reference/android/os/Build.VERSION.html#SDK_INT` is 26 or higher, or `https://developer.android.com/reference/android/content/Context.html#startService(android.content.Intent)` otherwise. |
| `static void` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi @https://checkerframework.org/api/com/google/errorprone/annotations/InlineMe.html(replacement = "service.stopForeground(removeNotification ? STOP_FOREGROUND_REMOVE :" + " STOP_FOREGROUND_DETACH)", staticImports = [""android.app.Service.STOP_FOREGROUND_DETACH"", ""android.app.Service.STOP_FOREGROUND_REMOVE""]) [stopForeground](https://developer.android.com/reference/androidx/media3/common/util/Util#stopForeground(android.app.Service,boolean))(https://developer.android.com/reference/android/app/Service.html service, boolean removeNotification)` **This method is deprecated.** Use `https://developer.android.com/reference/android/app/Service.html#stopForeground(int)` instead. <br /> |
| `static long` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#subtractWithOverflowDefault(long,long,long)(long x, long y, long overflowResult)` Returns the difference between two arguments, or a third argument if the result overflows. |
| `static long` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#sum(long...)(long[] summands)` Returns the sum of all summands of the given array. |
| `static boolean` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#tableExists(android.database.sqlite.SQLiteDatabase,java.lang.String)(https://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html database, https://developer.android.com/reference/java/lang/String.html tableName)` Returns whether the table exists in the database. |
| `static byte[]` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi [toByteArray](https://developer.android.com/reference/androidx/media3/common/util/Util#toByteArray(java.io.InputStream))(https://developer.android.com/reference/java/io/InputStream.html inputStream)` **This method is deprecated.** Use Guava's `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/io/ByteStreams.html#toByteArray(java.io.InputStream)` instead. <br /> |
| `static byte[]` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#toByteArray(float)(float value)` Converts a float into an equivalent byte array. |
| `static byte[]` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#toByteArray(int)(int value)` Converts a single integer into an equivalent 4-byte array in big-endian order. |
| `static byte[]` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#toByteArray(int...)(int[] values)` Converts an array of integers into an equivalent byte array. |
| `static https://developer.android.com/reference/java/lang/String.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#toFourccString(int)(int fourcc)` |
| `static https://developer.android.com/reference/java/lang/String.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#toHexString(byte[])(byte[] bytes)` Returns a string containing a lower-case hex representation of the bytes provided. |
| `static https://developer.android.com/reference/java/lang/String.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#toHexString(byte[],int,int)(byte[] bytes, int offset, int length)` Returns a string containing a lower-case hex representation of the bytes provided. |
| `static long` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#toLong(int,int)(int mostSignificantBits, int leastSignificantBits)` Returns the long that is composed of the bits of the 2 specified integers. |
| `static int` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#toUnsignedInt(long)(long x)` Converts a long to an int, checking that the long value fits within the range of an unsigned 32-bit integer. |
| `static long` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#toUnsignedLong(int)(int x)` Converts an integer to a long by unsigned conversion. |
| `static https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<T>` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi <T extends https://developer.android.com/reference/java/lang/Object.html, U extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/media3/common/util/Util#transformFutureAsync(com.google.common.util.concurrent.ListenableFuture<U>,com.google.common.util.concurrent.AsyncFunction<U,T>)( https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<U> future, https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/AsyncFunction.html<U, T> transformFunction )` Asynchronously transforms the result of a `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html`. |
| `static @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#unescapeFileName(java.lang.String)(https://developer.android.com/reference/java/lang/String.html fileName)` Unescapes an escaped file or directory name back to its original value. |
| `static long` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#usToMs(long)(long timeUs)` Converts a time in microseconds to the corresponding time in milliseconds, preserving `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` and `https://developer.android.com/reference/androidx/media3/common/C#TIME_END_OF_SOURCE()` values. |
| `static void` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/util/Util#writeBoolean(android.os.Parcel,boolean)(https://developer.android.com/reference/android/os/Parcel.html parcel, boolean value)` Writes a boolean to a `https://developer.android.com/reference/android/os/Parcel.html`. |

## Constants

### DEVICE

```
@UnstableApi
public static final String DEVICE
```

> [!CAUTION]
> **This field is deprecated.**   
>
> Use `https://developer.android.com/reference/android/os/Build.html#DEVICE` instead.

### DEVICE_DEBUG_INFO

```
@UnstableApi
public static final String DEVICE_DEBUG_INFO
```

A concise description of the device that it can be useful to log for debugging purposes.

### EMPTY_BYTE_ARRAY

```
@UnstableApi
public static final byte[] EMPTY_BYTE_ARRAY
```

An empty byte array.

### EMPTY_LONG_ARRAY

```
@UnstableApi
public static final long[] EMPTY_LONG_ARRAY
```

An empty long array.

### MANUFACTURER

```
@UnstableApi
public static final String MANUFACTURER
```

> [!CAUTION]
> **This field is deprecated.**   
>
> Use `https://developer.android.com/reference/android/os/Build.html#MANUFACTURER` instead.

### MODEL

```
@UnstableApi
public static final String MODEL
```

> [!CAUTION]
> **This field is deprecated.**   
>
> Use `https://developer.android.com/reference/android/os/Build.html#MODEL` instead.

### SDK_INT

```
@UnstableApi
public static final int SDK_INT
```

> [!CAUTION]
> **This field is deprecated.**   
>
> Use `https://developer.android.com/reference/android/os/Build.VERSION.html#SDK_INT` instead.

## Public methods

### addWithOverflowDefault

```
@UnstableApi
public static long addWithOverflowDefault(long x, long y, long overflowResult)
```

Returns the sum of two arguments, or a third argument if the result overflows.

| Parameters |
|---|---|
| `long x` | The first value. |
| `long y` | The second value. |
| `long overflowResult` | The return value if `x + y` overflows. |

| Returns |
|---|---|
| `long` | `x + y`, or `overflowResult` if the result overflows. |

### areEqual

```
@UnstableApi
@InlineMe(replacement = "Objects.equals(o1, o2)", imports = [""java.util.Objects""])
public static boolean [areEqual](https://developer.android.com/reference/androidx/media3/common/util/Util#areEqual(java.lang.Object,java.lang.Object))(@Nullable Object o1, @Nullable Object o2)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/java/util/Objects.html#equals(java.lang.Object, java.lang.Object)` instead.

### binarySearchCeil

```
@UnstableApi
public static int binarySearchCeil(
    int[] array,
    int value,
    boolean inclusive,
    boolean stayInBounds
)
```

Returns the index of the smallest element in `array` that is greater than (or optionally equal to) a specified `value`.

The search is performed using a binary search algorithm, so the array must be sorted. If the array contains multiple elements equal to `value` and `inclusive` is true, the index of the last one will be returned.

| Parameters |
|---|---|
| `int[] array` | The array to search. |
| `int value` | The value being searched for. |
| `boolean inclusive` | If the value is present in the array, whether to return the corresponding index. If false then the returned index corresponds to the smallest element strictly greater than the value. |
| `boolean stayInBounds` | If true, then `(a.length - 1)` will be returned in the case that the value is greater than the largest element in the array. If false then `a.length` will be returned. |

| Returns |
|---|---|
| `int` | The index of the smallest element in `array` that is greater than (or optionally equal to) `value`. |

### binarySearchCeil

```
@UnstableApi
public static int binarySearchCeil(
    long[] array,
    long value,
    boolean inclusive,
    boolean stayInBounds
)
```

Returns the index of the smallest element in `array` that is greater than (or optionally equal to) a specified `value`.

The search is performed using a binary search algorithm, so the array must be sorted. If the array contains multiple elements equal to `value` and `inclusive` is true, the index of the last one will be returned.

| Parameters |
|---|---|
| `long[] array` | The array to search. |
| `long value` | The value being searched for. |
| `boolean inclusive` | If the value is present in the array, whether to return the corresponding index. If false then the returned index corresponds to the smallest element strictly greater than the value. |
| `boolean stayInBounds` | If true, then `(a.length - 1)` will be returned in the case that the value is greater than the largest element in the array. If false then `a.length` will be returned. |

| Returns |
|---|---|
| `int` | The index of the smallest element in `array` that is greater than (or optionally equal to) `value`. |

### binarySearchCeil

```
@UnstableApi
public static int <T extends Comparable<T>> binarySearchCeil(
    List<Comparable<T>> list,
    T value,
    boolean inclusive,
    boolean stayInBounds
)
```

Returns the index of the smallest element in `list` that is greater than (or optionally equal to) a specified value.

The search is performed using a binary search algorithm, so the list must be sorted. If the list contains multiple elements equal to `value` and `inclusive` is true, the index of the last one will be returned.

| Parameters |
|---|---|
| `<T extends https://developer.android.com/reference/java/lang/Comparable.html<T>>` | The type of values being searched. |
| `https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/java/lang/Comparable.html<T>> list` | The list to search. |
| `T value` | The value being searched for. |
| `boolean inclusive` | If the value is present in the list, whether to return the corresponding index. If false then the returned index corresponds to the smallest element strictly greater than the value. |
| `boolean stayInBounds` | If true, then `(list.size() - 1)` will be returned in the case that the value is greater than the largest element in the list. If false then ` list.size()` will be returned. |

| Returns |
|---|---|
| `int` | The index of the smallest element in `list` that is greater than (or optionally equal to) `value`. |

### binarySearchFloor

```
@UnstableApi
public static int binarySearchFloor(
    int[] array,
    int value,
    boolean inclusive,
    boolean stayInBounds
)
```

Returns the index of the largest element in `array` that is less than (or optionally equal to) a specified `value`.

The search is performed using a binary search algorithm, so the array must be sorted. If the array contains multiple elements equal to `value` and `inclusive` is true, the index of the first one will be returned.

| Parameters |
|---|---|
| `int[] array` | The array to search. |
| `int value` | The value being searched for. |
| `boolean inclusive` | If the value is present in the array, whether to return the corresponding index. If false then the returned index corresponds to the largest element strictly less than the value. |
| `boolean stayInBounds` | If true, then 0 will be returned in the case that the value is smaller than the smallest element in the array. If false then -1 will be returned. |

| Returns |
|---|---|
| `int` | The index of the largest element in `array` that is less than (or optionally equal to) `value`. |

### binarySearchFloor

```
@UnstableApi
public static int binarySearchFloor(
    long[] array,
    long value,
    boolean inclusive,
    boolean stayInBounds
)
```

Returns the index of the largest element in `array` that is less than (or optionally equal to) a specified `value`.

The search is performed using a binary search algorithm, so the array must be sorted. If the array contains multiple elements equal to `value` and `inclusive` is true, the index of the first one will be returned.

| Parameters |
|---|---|
| `long[] array` | The array to search. |
| `long value` | The value being searched for. |
| `boolean inclusive` | If the value is present in the array, whether to return the corresponding index. If false then the returned index corresponds to the largest element strictly less than the value. |
| `boolean stayInBounds` | If true, then 0 will be returned in the case that the value is smaller than the smallest element in the array. If false then -1 will be returned. |

| Returns |
|---|---|
| `int` | The index of the largest element in `array` that is less than (or optionally equal to) `value`. |

### binarySearchFloor

```
@UnstableApi
public static int <T extends Comparable<T>> binarySearchFloor(
    List<Comparable<T>> list,
    T value,
    boolean inclusive,
    boolean stayInBounds
)
```

Returns the index of the largest element in `list` that is less than (or optionally equal to) a specified `value`.

The search is performed using a binary search algorithm, so the list must be sorted. If the list contains multiple elements equal to `value` and `inclusive` is true, the index of the first one will be returned.

| Parameters |
|---|---|
| `<T extends https://developer.android.com/reference/java/lang/Comparable.html<T>>` | The type of values being searched. |
| `https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/java/lang/Comparable.html<T>> list` | The list to search. |
| `T value` | The value being searched for. |
| `boolean inclusive` | If the value is present in the list, whether to return the corresponding index. If false then the returned index corresponds to the largest element strictly less than the value. |
| `boolean stayInBounds` | If true, then 0 will be returned in the case that the value is smaller than the smallest element in the list. If false then -1 will be returned. |

| Returns |
|---|---|
| `int` | The index of the largest element in `list` that is less than (or optionally equal to) `value`. |

### binarySearchFloor

```
@UnstableApi
public static int binarySearchFloor(
    LongArray longArray,
    long value,
    boolean inclusive,
    boolean stayInBounds
)
```

Returns the index of the largest element in `longArray` that is less than (or optionally equal to) a specified `value`.

The search is performed using a binary search algorithm, so the array must be sorted. If the array contains multiple elements equal to `value` and `inclusive` is true, the index of the first one will be returned.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/util/LongArray longArray` | The array to search. |
| `long value` | The value being searched for. |
| `boolean inclusive` | If the value is present in the array, whether to return the corresponding index. If false then the returned index corresponds to the largest element strictly less than the value. |
| `boolean stayInBounds` | If true, then 0 will be returned in the case that the value is smaller than the smallest element in the array. If false then -1 will be returned. |

| Returns |
|---|---|
| `int` | The index of the largest element in `array` that is less than (or optionally equal to) `value`. |

### castNonNull

```
@UnstableApi
@EnsuresNonNull(value = "#1")
public static T <T> castNonNull(@Nullable T value)
```

Casts a nullable variable to a non-null variable without runtime null check.

Use `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/base/Preconditions.html#checkNotNull(T)` to throw if the value is null.

### castNonNullTypeArray

```
@UnstableApi
@EnsuresNonNull(value = "#1")
public static T[] <T> castNonNullTypeArray(@NullableType T[] value)
```

Casts a nullable type array to a non-null type array without runtime null check.

### ceilDivide

```
@UnstableApi
public static int ceilDivide(int numerator, int denominator)
```

Divides a `numerator` by a `denominator`, returning the ceiled result.

| Parameters |
|---|---|
| `int numerator` | The numerator to divide. |
| `int denominator` | The denominator to divide by. |

| Returns |
|---|---|
| `int` | The ceiled result of the division. |

### ceilDivide

```
@UnstableApi
public static long ceilDivide(long numerator, long denominator)
```

Divides a `numerator` by a `denominator`, returning the ceiled result.

| Parameters |
|---|---|
| `long numerator` | The numerator to divide. |
| `long denominator` | The denominator to divide by. |

| Returns |
|---|---|
| `long` | The ceiled result of the division. |

### checkCleartextTrafficPermitted

```
public static boolean checkCleartextTrafficPermitted(MediaItem[] mediaItems)
```

Returns whether it may be possible to load the URIs of the given media items based on the network security policy's cleartext traffic permissions.

| Parameters |
|---|---|
| `MediaItem[] mediaItems` | A list of `https://developer.android.com/reference/androidx/media3/common/MediaItem`. |

| Returns |
|---|---|
| `boolean` | Whether it may be possible to load the URIs of the given media items. |

### closeQuietly

```
@UnstableApi
public static void closeQuietly(@Nullable Closeable closeable)
```

Closes a `https://developer.android.com/reference/java/io/Closeable.html`, suppressing any `https://developer.android.com/reference/java/io/IOException.html` that may occur. Both `https://developer.android.com/reference/java/io/OutputStream.html` and `https://developer.android.com/reference/java/io/InputStream.html` are `Closeable`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/io/Closeable.html closeable` | The `https://developer.android.com/reference/java/io/Closeable.html` to close. |

### compareLong

```
@UnstableApi
@InlineMe(replacement = "Long.compare(left, right)")
public static int [compareLong](https://developer.android.com/reference/androidx/media3/common/util/Util#compareLong(long,long))(long left, long right)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/java/lang/Long.html#compare(long, long)`.

### constrainValue

```
@UnstableApi
public static double constrainValue(double value, double min, double max)
```

Constrains a value to the specified bounds.

| Parameters |
|---|---|
| `double value` | The value to constrain. |
| `double min` | The lower bound. |
| `double max` | The upper bound. |

| Returns |
|---|---|
| `double` | The constrained value `Math.max(min, Math.min(value, max))`. |

### constrainValue

```
@UnstableApi
public static float constrainValue(float value, float min, float max)
```

Constrains a value to the specified bounds.

| Parameters |
|---|---|
| `float value` | The value to constrain. |
| `float min` | The lower bound. |
| `float max` | The upper bound. |

| Returns |
|---|---|
| `float` | The constrained value `Math.max(min, Math.min(value, max))`. |

### constrainValue

```
@UnstableApi
public static int constrainValue(int value, int min, int max)
```

Constrains a value to the specified bounds.

| Parameters |
|---|---|
| `int value` | The value to constrain. |
| `int min` | The lower bound. |
| `int max` | The upper bound. |

| Returns |
|---|---|
| `int` | The constrained value `Math.max(min, Math.min(value, max))`. |

### constrainValue

```
@UnstableApi
public static long constrainValue(long value, long min, long max)
```

Constrains a value to the specified bounds.

| Parameters |
|---|---|
| `long value` | The value to constrain. |
| `long min` | The lower bound. |
| `long max` | The upper bound. |

| Returns |
|---|---|
| `long` | The constrained value `Math.max(min, Math.min(value, max))`. |

### contains

```
@UnstableApi
public static boolean contains(@NullableType Object[] items, @Nullable Object item)
```

Tests whether an `items` array contains an object equal to `item`, according to `https://developer.android.com/reference/java/lang/Object.html#equals(java.lang.Object)`.

If `item` is null then true is returned if and only if `items` contains null.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/media3/common/util/NullableType Object[] items` | The array of items to search. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html item` | The item to search for. |

| Returns |
|---|---|
| `boolean` | True if the array contains an object equal to the item being searched for. |

### contains

```
@UnstableApi
public static boolean <T> contains(SparseArray<T> sparseArray, int key)
```

Tests whether a `https://developer.android.com/reference/android/util/SparseArray.html` contains a given `key`.

This implements `SparseArray#contains` for lower API versions.

### contains

```
@UnstableApi
public static boolean contains(SparseBooleanArray sparseArray, int key)
```

Returns whether the given `https://developer.android.com/reference/android/util/SparseBooleanArray.html` contains the given key.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/util/SparseBooleanArray.html sparseArray` | The `https://developer.android.com/reference/android/util/SparseBooleanArray.html`. |
| `int key` | The key. |

| Returns |
|---|---|
| `boolean` | Whether the `https://developer.android.com/reference/android/util/SparseBooleanArray.html` contains the key. |

### contains

```
@UnstableApi
public static boolean contains(SparseIntArray sparseArray, int key)
```

Returns whether the given `https://developer.android.com/reference/android/util/SparseIntArray.html` contains the given key.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/util/SparseIntArray.html sparseArray` | The `https://developer.android.com/reference/android/util/SparseIntArray.html`. |
| `int key` | The key. |

| Returns |
|---|---|
| `boolean` | Whether the `https://developer.android.com/reference/android/util/SparseIntArray.html` contains the key. |

### contentEquals

```
@UnstableApi
public static boolean <T> contentEquals(
    @Nullable SparseArray<T> sparseArray1,
    @Nullable SparseArray<T> sparseArray2
)
```

Tests two `https://developer.android.com/reference/android/util/SparseArray.html` instances for content equality, handling the case where one or both may be `null`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/util/SparseArray.html<T> sparseArray1` | The first `https://developer.android.com/reference/android/util/SparseArray.html` instance. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/util/SparseArray.html<T> sparseArray2` | The second `https://developer.android.com/reference/android/util/SparseArray.html` instance. |

| Returns |
|---|---|
| `boolean` | True if the two `https://developer.android.com/reference/android/util/SparseArray.html` instances are equal in contents. |

| See also |
|---|---|
| `https://developer.android.com/reference/android/util/SparseArray.html#contentEquals(android.util.SparseArray&lt;?&gt;)` |   |

### contentHashCode

```
@UnstableApi
public static int <T> contentHashCode(SparseArray<T> sparseArray)
```

Returns a hash code value for the contents of this `https://developer.android.com/reference/android/util/SparseArray.html`, combining the `https://developer.android.com/reference/java/util/Objects.html#hashCode(java.lang.Object)` result of all its keys and values.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/util/SparseArray.html<T> sparseArray` | The `https://developer.android.com/reference/android/util/SparseArray.html` instance. |

| Returns |
|---|---|
| `int` | The hash code. |

| See also |
|---|---|
| `https://developer.android.com/reference/android/util/SparseArray.html#contentHashCode()` |   |

### convertToNullIfInvalid

```
@CheckReturnValue
@UnstableApi
public static @Nullable Bundle convertToNullIfInvalid(@Nullable Bundle bundle)
```

Converts the provided `https://developer.android.com/reference/android/os/Bundle.html` to `null` if it is invalid.

Typical reasons for why the validation may fail are `https://developer.android.com/reference/android/os/Parcelable.html` classes in this bundle that are not part of the app class loader or a corrupt internal state caused by concurrent writes.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/os/Bundle.html bundle` | The `https://developer.android.com/reference/android/os/Bundle.html` to verify, or null. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/os/Bundle.html` | The same `https://developer.android.com/reference/android/os/Bundle.html`, or null if the verification failed or the parameter is null. |

### crc16

```
@UnstableApi
public static int crc16(byte[] bytes, int start, int end, int initialValue)
```

Returns the result of updating a CRC-16 with the specified bytes in a "most significant bit first" order.

| Parameters |
|---|---|
| `byte[] bytes` | Array containing the bytes to update the crc value with. |
| `int start` | The start index (inclusive) of the byte range to update the crc with. |
| `int end` | The end index (exclusive) of the byte range to update the crc with. |
| `int initialValue` | The initial value for the crc calculation. The lower 16 bits of this 32-bit integer are used for the CRC computation. |

| Returns |
|---|---|
| `int` | The result of updating the initial value with the specified bytes. |

### crc32

```
@UnstableApi
public static int crc32(byte[] bytes, int start, int end, int initialValue)
```

Returns the result of updating a CRC-32 with the specified bytes in a "most significant bit first" order.

| Parameters |
|---|---|
| `byte[] bytes` | Array containing the bytes to update the crc value with. |
| `int start` | The index to the first byte in the byte range to update the crc with. |
| `int end` | The index after the last byte in the byte range to update the crc with. |
| `int initialValue` | The initial value for the crc calculation. |

| Returns |
|---|---|
| `int` | The result of updating the initial value with the specified bytes. |

### crc8

```
@UnstableApi
public static int crc8(byte[] bytes, int start, int end, int initialValue)
```

Returns the result of updating a CRC-8 with the specified bytes in a "most significant bit first" order.

| Parameters |
|---|---|
| `byte[] bytes` | Array containing the bytes to update the crc value with. |
| `int start` | The index to the first byte in the byte range to update the crc with. |
| `int end` | The index after the last byte in the byte range to update the crc with. |
| `int initialValue` | The initial value for the crc calculation. |

| Returns |
|---|---|
| `int` | The result of updating the initial value with the specified bytes. |

### createHandler

```
@UnstableApi
public static Handler createHandler(
    Looper looper,
    @Nullable @UnknownInitialization Handler.Callback callback
)
```

Creates a `https://developer.android.com/reference/android/os/Handler.html` with the specified `https://developer.android.com/reference/android/os/Handler.Callback.html` on the specified `https://developer.android.com/reference/android/os/Looper.html` thread.

The method accepts partially initialized objects as callback under the assumption that the Handler won't be used to send messages until the callback is fully initialized.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/os/Looper.html looper` | A `https://developer.android.com/reference/android/os/Looper.html` to run the callback on. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable @https://checkerframework.org/api/org/checkerframework/checker/initialization/qual/UnknownInitialization.html https://developer.android.com/reference/android/os/Handler.Callback.html callback` | A `https://developer.android.com/reference/android/os/Handler.Callback.html`. May be a partially initialized class, or null if no callback is required. |

| Returns |
|---|---|
| `https://developer.android.com/reference/android/os/Handler.html` | A `https://developer.android.com/reference/android/os/Handler.html` with the specified callback on the current `https://developer.android.com/reference/android/os/Looper.html` thread. |

### createHandlerForCurrentLooper

```
@UnstableApi
public static Handler createHandlerForCurrentLooper()
```

Creates a `https://developer.android.com/reference/android/os/Handler.html` on the current `https://developer.android.com/reference/android/os/Looper.html` thread.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | If the current thread doesn't have a `https://developer.android.com/reference/android/os/Looper.html`. |

### createHandlerForCurrentLooper

```
@UnstableApi
public static Handler createHandlerForCurrentLooper(
    @Nullable @UnknownInitialization Handler.Callback callback
)
```

Creates a `https://developer.android.com/reference/android/os/Handler.html` with the specified `https://developer.android.com/reference/android/os/Handler.Callback.html` on the current `https://developer.android.com/reference/android/os/Looper.html` thread.

The method accepts partially initialized objects as callback under the assumption that the Handler won't be used to send messages until the callback is fully initialized.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable @https://checkerframework.org/api/org/checkerframework/checker/initialization/qual/UnknownInitialization.html https://developer.android.com/reference/android/os/Handler.Callback.html callback` | A `https://developer.android.com/reference/android/os/Handler.Callback.html`. May be a partially initialized class, or null if no callback is required. |

| Returns |
|---|---|
| `https://developer.android.com/reference/android/os/Handler.html` | A `https://developer.android.com/reference/android/os/Handler.html` with the specified callback on the current `https://developer.android.com/reference/android/os/Looper.html` thread. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | If the current thread doesn't have a `https://developer.android.com/reference/android/os/Looper.html`. |

### createHandlerForCurrentOrMainLooper

```
@UnstableApi
public static Handler createHandlerForCurrentOrMainLooper()
```

Creates a `https://developer.android.com/reference/android/os/Handler.html` on the current `https://developer.android.com/reference/android/os/Looper.html` thread.

If the current thread doesn't have a `https://developer.android.com/reference/android/os/Looper.html`, the application's main thread `https://developer.android.com/reference/android/os/Looper.html` is used.

### createHandlerForCurrentOrMainLooper

```
@UnstableApi
public static Handler createHandlerForCurrentOrMainLooper(
    @Nullable @UnknownInitialization Handler.Callback callback
)
```

Creates a `https://developer.android.com/reference/android/os/Handler.html` with the specified `https://developer.android.com/reference/android/os/Handler.Callback.html` on the current `https://developer.android.com/reference/android/os/Looper.html` thread.

The method accepts partially initialized objects as callback under the assumption that the Handler won't be used to send messages until the callback is fully initialized.

If the current thread doesn't have a `https://developer.android.com/reference/android/os/Looper.html`, the application's main thread `https://developer.android.com/reference/android/os/Looper.html` is used.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable @https://checkerframework.org/api/org/checkerframework/checker/initialization/qual/UnknownInitialization.html https://developer.android.com/reference/android/os/Handler.Callback.html callback` | A `https://developer.android.com/reference/android/os/Handler.Callback.html`. May be a partially initialized class, or null if no callback is required. |

| Returns |
|---|---|
| `https://developer.android.com/reference/android/os/Handler.html` | A `https://developer.android.com/reference/android/os/Handler.html` with the specified callback on the current `https://developer.android.com/reference/android/os/Looper.html` thread. |

### createReadOnlyByteBuffer

```
@UnstableApi
public static ByteBuffer createReadOnlyByteBuffer(ByteBuffer byteBuffer)
```

Returns a read-only view of the given `https://developer.android.com/reference/java/nio/ByteBuffer.html`.

This behaves the same as `https://developer.android.com/reference/java/nio/ByteBuffer.html#asReadOnlyBuffer()` whilst preserving the `https://developer.android.com/reference/java/nio/ByteOrder.html` of the original buffer.

### createTempDirectory

```
@UnstableApi
public static File createTempDirectory(Context context, String prefix)
```

Creates an empty directory in the directory returned by `https://developer.android.com/reference/android/content/Context.html#getCacheDir()`.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` |   |

### createTempFile

```
@UnstableApi
public static File createTempFile(Context context, String prefix)
```

Creates a new empty file in the directory returned by `https://developer.android.com/reference/android/content/Context.html#getCacheDir()`.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` |   |

### durationUsToSampleCount

```
@UnstableApi
public static long durationUsToSampleCount(long durationUs, int sampleRate)
```

Returns the number of samples required to represent `durationUs` of media at `
sampleRate`, assuming all samples are equal duration except the last one which may be shorter.

The result of this method **cannot** be generally reversed to the original duration with `https://developer.android.com/reference/androidx/media3/common/util/Util#sampleCountToDurationUs(long,int)`, due to information lost when rounding to a whole number of samples.

| Parameters |
|---|---|
| `long durationUs` | The duration in microseconds. |
| `int sampleRate` | The sample rate in samples per second. |

| Returns |
|---|---|
| `long` | The number of samples required to represent `durationUs`. |

### ensureNotificationChannel

```
@UnstableApi
public static void ensureNotificationChannel(
    NotificationManager notificationManager,
    String channelId,
    String channelName
)
```

Ensure that the `https://developer.android.com/reference/android/app/NotificationChannel.html` with the given channel ID exists. If not existing, the channel is created.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/app/NotificationManager.html notificationManager` | The `https://developer.android.com/reference/android/app/NotificationManager.html` to create the channel with. |
| `https://developer.android.com/reference/java/lang/String.html channelId` | The channel ID. |
| `https://developer.android.com/reference/java/lang/String.html channelName` | The channel name. |

### escapeFileName

```
@UnstableApi
public static String escapeFileName(String fileName)
```

Escapes a string so that it's safe for use as a file or directory name on at least FAT32 filesystems. FAT32 is the most restrictive of all filesystems still commonly used today.

For simplicity, this only handles common characters known to be illegal on FAT32: \<, \>, :, ", /, \\, \|, ?, and \*. % is also escaped since it is used as the escape character. Escaping is performed in a consistent way so that no collisions occur and `https://developer.android.com/reference/androidx/media3/common/util/Util#unescapeFileName(java.lang.String)` can be used to retrieve the original file name.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html fileName` | File name to be escaped. |

| Returns |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html` | An escaped file name which will be safe for use on at least FAT32 filesystems. |

### fixSmoothStreamingIsmManifestUri

```
@UnstableApi
public static Uri fixSmoothStreamingIsmManifestUri(Uri uri)
```

If the provided URI is an ISM Presentation URI, returns the URI with "Manifest" appended to its path (i.e., the corresponding default manifest URI). Else returns the provided URI without modification. See \[MS-SSTR\] v20180912, section 2.2.1.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/net/Uri.html uri` | The original URI. |

| Returns |
|---|---|
| `https://developer.android.com/reference/android/net/Uri.html` | The fixed URI. |

### formatInvariant

```
@UnstableApi
public static String formatInvariant(String format, Object[] args)
```

Formats a string using `https://developer.android.com/reference/java/util/Locale.html#US`.

| See also |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html#format(java.lang.String, java.lang.Object...)` |   |

### fromUtf8Bytes

```
@UnstableApi
public static String fromUtf8Bytes(byte[] bytes)
```

Returns a new `https://developer.android.com/reference/java/lang/String.html` constructed by decoding UTF-8 encoded bytes.

| Parameters |
|---|---|
| `byte[] bytes` | The UTF-8 encoded bytes to decode. |

| Returns |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html` | The string. |

### fromUtf8Bytes

```
@UnstableApi
public static String fromUtf8Bytes(byte[] bytes, int offset, int length)
```

Returns a new `https://developer.android.com/reference/java/lang/String.html` constructed by decoding UTF-8 encoded bytes in a subarray.

| Parameters |
|---|---|
| `byte[] bytes` | The UTF-8 encoded bytes to decode. |
| `int offset` | The index of the first byte to decode. |
| `int length` | The number of bytes to decode. |

| Returns |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html` | The string. |

### generateAudioSessionId

```
@UnstableApi
public static int generateAudioSessionId(Context context)
```

Returns a newly generated audio session identifier, or `https://developer.android.com/reference/androidx/media3/common/C#AUDIO_SESSION_ID_UNSET()` if failed to generate an identifier and in which case audio playback may fail.

| See also |
|---|---|
| `https://developer.android.com/reference/android/media/AudioManager.html#generateAudioSessionId()` |   |

### generateAudioSessionIdV21

```
@UnstableApi
@InlineMe(replacement = "Util.generateAudioSessionId(context)", imports = "androidx.media3.common.util.Util")
public static int [generateAudioSessionIdV21](https://developer.android.com/reference/androidx/media3/common/util/Util#generateAudioSessionIdV21(android.content.Context))(Context context)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/media3/common/util/Util#generateAudioSessionId(android.content.Context)` instead.

### getAdaptiveMimeTypeForContentType

```
public static @Nullable String getAdaptiveMimeTypeForContentType(@C.ContentType int contentType)
```

Returns the MIME type corresponding to the given adaptive `https://developer.android.com/reference/androidx/media3/common/C.ContentType`, or `null` if the content type is not adaptive.

### getApiLevelThatAudioFormatIntroducedAudioEncoding

```
@UnstableApi
public static int getApiLevelThatAudioFormatIntroducedAudioEncoding(int encoding)
```

Retrieves the API Level that `https://developer.android.com/reference/android/media/AudioFormat.html` introduced an encoding.

Method returns `https://developer.android.com/reference/java/lang/Integer.html#MAX_VALUE` if the encoding is unknown.

| Parameters |
|---|---|
| `int encoding` | for which to get the API level. |

### getAudioContentTypeForStreamType

```
@UnstableApi
@C.AudioContentType
public static int [getAudioContentTypeForStreamType](https://developer.android.com/reference/androidx/media3/common/util/Util#getAudioContentTypeForStreamType(int))(@C.StreamType int streamType)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> This method is no longer used by the media3 library, it does not work well and should be avoided. There is no direct replacement.

### getAudioFormat

```
@UnstableApi
public static AudioFormat getAudioFormat(int sampleRate, int channelConfig, int encoding)
```

Creates `https://developer.android.com/reference/android/media/AudioFormat.html` with given sampleRate, channelConfig, and encoding.

### getAudioTrackChannelConfig

```
@UnstableApi
public static int getAudioTrackChannelConfig(int channelCount)
```

Returns the audio track channel configuration for the given channel count, or `https://developer.android.com/reference/android/media/AudioFormat.html#CHANNEL_INVALID` if output is not possible.

| Parameters |
|---|---|
| `int channelCount` | The number of channels in the input audio. |

| Returns |
|---|---|
| `int` | The channel configuration or `https://developer.android.com/reference/android/media/AudioFormat.html#CHANNEL_INVALID` if output is not possible. |

### getAudioTrackChannelConfig

```
@UnstableApi
public static int getAudioTrackChannelConfig(Format format)
```

Returns the audio track channel configuration for the given `https://developer.android.com/reference/androidx/media3/common/Format`, or `https://developer.android.com/reference/android/media/AudioFormat.html#CHANNEL_INVALID` if output is not possible.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Format format` | The `https://developer.android.com/reference/androidx/media3/common/Format` of the input audio. |

| Returns |
|---|---|
| `int` | The channel configuration or `https://developer.android.com/reference/android/media/AudioFormat.html#CHANNEL_INVALID` if output is not possible. |

### getAudioUsageForStreamType

```
@UnstableApi
@C.AudioUsage
public static int getAudioUsageForStreamType(@C.StreamType int streamType)
```

Returns the `https://developer.android.com/reference/androidx/media3/common/C.AudioUsage` corresponding to the specified `https://developer.android.com/reference/androidx/media3/common/C.StreamType`.

### getAuxiliaryTrackTypeString

```
@UnstableApi
public static String getAuxiliaryTrackTypeString(
    @C.AuxiliaryTrackType int auxiliaryTrackType
)
```

Returns a string representation of the `https://developer.android.com/reference/androidx/media3/common/C.AuxiliaryTrackType`.

### getAvailableCommands

```
@UnstableApi
public static Player.Commands getAvailableCommands(
    Player player,
    Player.Commands permanentAvailableCommands
)
```

Returns the `https://developer.android.com/reference/androidx/media3/common/Player.Commands` available in the `https://developer.android.com/reference/androidx/media3/common/Player`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Player player` | The `https://developer.android.com/reference/androidx/media3/common/Player`. |
| `https://developer.android.com/reference/androidx/media3/common/Player.Commands permanentAvailableCommands` | The commands permanently available in the player. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Player.Commands` | The available `https://developer.android.com/reference/androidx/media3/common/Player.Commands`. |

### getBigEndianInt

```
@UnstableApi
public static int getBigEndianInt(ByteBuffer buffer, int index)
```

Absolute *get* method for reading an int value in `https://developer.android.com/reference/java/nio/ByteOrder.html#BIG_ENDIAN` in a `https://developer.android.com/reference/java/nio/ByteBuffer.html`. Same as `https://developer.android.com/reference/java/nio/ByteBuffer.html#getInt(int)` except the buffer's order as returned by `https://developer.android.com/reference/java/nio/ByteBuffer.html#order()` is ignored and `https://developer.android.com/reference/java/nio/ByteOrder.html#BIG_ENDIAN` is used instead.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/nio/ByteBuffer.html buffer` | The buffer from which to read an int in big endian. |
| `int index` | The index from which the bytes will be read. |

| Returns |
|---|---|
| `int` | The int value at the given index with the buffer bytes ordered most significant to least significant. |

### getBufferFlagsFromMediaCodecFlags

```
@UnstableApi
@C.BufferFlags
public static int getBufferFlagsFromMediaCodecFlags(int mediaCodecFlags)
```

Returns `https://developer.android.com/reference/androidx/media3/common/C.BufferFlags` corresponding to `https://developer.android.com/reference/android/media/MediaCodec.html` flags.

### getByteDepth

```
@UnstableApi
public static int getByteDepth(@C.PcmEncoding int pcmEncoding)
```

Returns the byte depth for audio with the specified encoding.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/media3/common/C.PcmEncoding int pcmEncoding` | The encoding of the audio data. Value is one of the following: - `Format.NO_VALUE` <br /> |

| Returns |
|---|---|
| `int` | The byte depth of the audio. |

### getBytesFromHexString

```
@UnstableApi
public static byte[] getBytesFromHexString(String hexString)
```

Returns a byte array containing values parsed from the hex string provided.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html hexString` | The hex string to convert to bytes. |

| Returns |
|---|---|
| `byte[]` | A byte array containing values parsed from the hex string provided. |

### getCodecCountOfType

```
@UnstableApi
public static int getCodecCountOfType(@Nullable String codecs, @C.TrackType int trackType)
```

Returns the number of codec strings in `codecs` whose type matches `trackType`.

### getCodecsOfType

```
@UnstableApi
public static @Nullable String getCodecsOfType(@Nullable String codecs, @C.TrackType int trackType)
```

Returns a copy of `codecs` without the codecs whose track type doesn't match `
trackType`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html codecs` | A codec sequence string, as defined in RFC 6381. |
| `@https://developer.android.com/reference/androidx/media3/common/C.TrackType int trackType` | The `https://developer.android.com/reference/androidx/media3/common/C.TrackType`. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html` | A copy of `codecs` without the codecs whose track type doesn't match ` trackType`. If this ends up empty, or `codecs` is null, returns null. |

### getCodecsWithoutType

```
@UnstableApi
public static @Nullable String getCodecsWithoutType(@Nullable String codecs, @C.TrackType int trackType)
```

Returns a copy of `codecs` without the codecs whose track type matches `trackType`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html codecs` | A codec sequence string, as defined in RFC 6381. |
| `@https://developer.android.com/reference/androidx/media3/common/C.TrackType int trackType` | The `https://developer.android.com/reference/androidx/media3/common/C.TrackType`. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html` | A copy of `codecs` without the codecs whose track type matches `trackType`. If this ends up empty, or `codecs` is null, returns null. |

### getColorInfoForDolbyVision

```
@UnstableApi
public static @Nullable ColorInfo getColorInfoForDolbyVision(
    @Nullable String codecs,
    @Nullable String supplementalCodecs,
    @Nullable String supplementalProfiles
)
```

Returns the `https://developer.android.com/reference/androidx/media3/common/ColorInfo` for specific Dolby Vision codecs and profiles.

This method only supports providing `https://developer.android.com/reference/androidx/media3/common/ColorInfo` for the following Dolby Vision codecs and profiles:

- Dolby Vision profiles 5, 10.0, and 20.0
- Dolby Vision profiles 8.1 and 8.4 when providing supplemental profile values

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html codecs` | A codec sequence string, as defined in RFC 6381. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html supplementalCodecs` | An optional RFC 6381 codecs string for supplemental codecs. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html supplementalProfiles` | Optional supplemental profile info. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/ColorInfo` | The `https://developer.android.com/reference/androidx/media3/common/ColorInfo` for specific Dolby Vision codecs and profiles and otherwise null. |

### getCountryCode

```
@UnstableApi
public static String getCountryCode(@Nullable Context context)
```

Returns the upper-case ISO 3166-1 alpha-2 country code of the current registered operator's MCC (Mobile Country Code), or the country code of the default Locale if not available.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/content/Context.html context` | A context to access the telephony service. If null, only the Locale can be used. |

| Returns |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html` | The upper-case ISO 3166-1 alpha-2 country code, or an empty String if unavailable. |

### getCurrentDisplayModeSize

```
@UnstableApi
public static Point getCurrentDisplayModeSize(Context context)
```

Gets the size of the current mode of the default display, in pixels.

Note that due to application UI scaling, the number of pixels made available to applications (as reported by `https://developer.android.com/reference/android/view/Display.html#getSize(android.graphics.Point)` may differ from the mode's actual resolution (as reported by this function). For example, applications running on a display configured with a 4K mode may have their UI laid out and rendered in 1080p and then scaled up. Applications can take advantage of the full mode resolution through a `https://developer.android.com/reference/android/view/SurfaceView.html` using full size buffers.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/content/Context.html context` | Any context. |

| Returns |
|---|---|
| `https://developer.android.com/reference/android/graphics/Point.html` | The size of the current mode, in pixels. |

### getCurrentDisplayModeSize

```
@UnstableApi
public static Point getCurrentDisplayModeSize(Context context, Display display)
```

Gets the size of the current mode of the specified display, in pixels.

Note that due to application UI scaling, the number of pixels made available to applications (as reported by `https://developer.android.com/reference/android/view/Display.html#getSize(android.graphics.Point)` may differ from the mode's actual resolution (as reported by this function). For example, applications running on a display configured with a 4K mode may have their UI laid out and rendered in 1080p and then scaled up. Applications can take advantage of the full mode resolution through a `https://developer.android.com/reference/android/view/SurfaceView.html` using full size buffers.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/content/Context.html context` | Any context. |
| `https://developer.android.com/reference/android/view/Display.html display` | The display whose size is to be returned. |

| Returns |
|---|---|
| `https://developer.android.com/reference/android/graphics/Point.html` | The size of the current mode, in pixels. |

### getCurrentOrMainLooper

```
@UnstableApi
public static Looper getCurrentOrMainLooper()
```

Returns the `https://developer.android.com/reference/android/os/Looper.html` associated with the current thread, or the `https://developer.android.com/reference/android/os/Looper.html` of the application's main thread if the current thread doesn't have a `https://developer.android.com/reference/android/os/Looper.html`.

### getDataUriForString

```
@UnstableApi
public static Uri getDataUriForString(String mimeType, String data)
```

Returns a data URI with the specified MIME type and data.

### getDefaultDisplayLocale

```
@UnstableApi
@InlineMe(replacement = "Locale.getDefault(Locale.Category.DISPLAY)", imports = [""java.util.Locale""])
public static Locale [getDefaultDisplayLocale](https://developer.android.com/reference/androidx/media3/common/util/Util#getDefaultDisplayLocale())()
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/java/util/Locale.html#getDefault(java.util.Locale.Category)` with `https://developer.android.com/reference/java/util/Locale.Category.html#DISPLAY` instead.

### getDrawable

```
@UnstableApi
public static Drawable getDrawable(
    Context context,
    Resources resources,
    @DrawableRes int drawableRes
)
```

Returns a `https://developer.android.com/reference/android/graphics/drawable/Drawable.html` for the given resource or throws a `https://developer.android.com/reference/android/content/res/Resources.NotFoundException.html` if not found.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/content/Context.html context` | The context to get the theme from. |
| `https://developer.android.com/reference/android/content/res/Resources.html resources` | The resources to load the drawable from. |
| `@https://developer.android.com/reference/androidx/annotation/DrawableRes int drawableRes` | The drawable resource int. |

| Returns |
|---|---|
| `https://developer.android.com/reference/android/graphics/drawable/Drawable.html` | The loaded `https://developer.android.com/reference/android/graphics/drawable/Drawable.html`. |

### getDrmUuid

```
public static @Nullable UUID getDrmUuid(String drmScheme)
```

Derives a DRM `https://developer.android.com/reference/java/util/UUID.html` from `drmScheme`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html drmScheme` | A UUID string, or `"widevine"`, `"playready"` or ` "clearkey"`. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/util/UUID.html` | The derived `https://developer.android.com/reference/java/util/UUID.html`, or `null` if one could not be derived. |

### getEncodingString

```
@UnstableApi
public static String getEncodingString(@C.Encoding int encoding)
```

Returns a user-readable string representation of the given `https://developer.android.com/reference/androidx/media3/common/C.Encoding`.

This method is intended for testing and debugging purposes only. The returned string format is not guaranteed to be stable.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/media3/common/C.Encoding int encoding` | The `https://developer.android.com/reference/androidx/media3/common/C.Encoding` value. Value is one of the following: - `Format.NO_VALUE` <br /> |

| Returns |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html` | A string representation of the encoding. |

### getErrorCodeForMediaDrmErrorCode

```
@UnstableApi
@PlaybackException.ErrorCode
public static int getErrorCodeForMediaDrmErrorCode(int mediaDrmErrorCode)
```

Returns a `https://developer.android.com/reference/androidx/media3/common/PlaybackException.ErrorCode` value that corresponds to the provided `https://developer.android.com/reference/android/media/MediaDrm.ErrorCodes.html` value. Returns `https://developer.android.com/reference/androidx/media3/common/PlaybackException#ERROR_CODE_DRM_SYSTEM_ERROR()` if the provided error code isn't recognised.

### getErrorCodeFromPlatformDiagnosticsInfo

```
@UnstableApi
public static int getErrorCodeFromPlatformDiagnosticsInfo(
    @Nullable String diagnosticsInfo
)
```

Attempts to parse an error code from a diagnostic string found in framework media exceptions.

For example: android.media.MediaCodec.error_1 or android.media.MediaDrm.error_neg_2.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html diagnosticsInfo` | A string from which to parse the error code. |

| Returns |
|---|---|
| `int` | The parsed error code, or 0 if an error code could not be parsed. |

### getFloatPcmEncoding

```
@UnstableApi
@C.PcmEncoding
public static int getFloatPcmEncoding(int bitDepth)
```

Converts a sample bit depth to a corresponding little-endian float PCM encoding constant.

Value is one of the following:

- `Format.NO_VALUE`

<br />

| Parameters |
|---|---|
| `int bitDepth` | The bit depth. Supported values are 32 and 64. |

| Returns |
|---|---|
| `int` | The corresponding float PCM encoding. If the bit depth is unsupported then `https://developer.android.com/reference/androidx/media3/common/C#ENCODING_INVALID()` is returned. |

### getFloatPcmEncoding

```
@UnstableApi
@C.PcmEncoding
public static int getFloatPcmEncoding(int bitDepth, ByteOrder byteOrder)
```

Converts a sample bit depth and byte order to a corresponding float PCM encoding constant.

Value is one of the following:

- `Format.NO_VALUE`

<br />

| Parameters |
|---|---|
| `int bitDepth` | The bit depth. Supported values are 32 and 64. |
| `https://developer.android.com/reference/java/nio/ByteOrder.html byteOrder` | The byte order. |

| Returns |
|---|---|
| `int` | The corresponding float PCM encoding. If the bit depth is unsupported then `https://developer.android.com/reference/androidx/media3/common/C#ENCODING_INVALID()` is returned. |

### getFormatSupportString

```
@UnstableApi
public static String getFormatSupportString(@C.FormatSupport int formatSupport)
```

Returns string representation of a `https://developer.android.com/reference/androidx/media3/common/C.FormatSupport` flag.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/media3/common/C.FormatSupport int formatSupport` | A `https://developer.android.com/reference/androidx/media3/common/C.FormatSupport` flag. |

| Returns |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html` | A string representation of the flag. |

### getInt24

```
@UnstableApi
public static int getInt24(ByteBuffer buffer, int index)
```

Returns the sign-extended 24-bit integer value at `index`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/nio/ByteBuffer.html buffer` | The buffer from which to read the 24-bit integer. |
| `int index` | The index of the 24-bit integer. |

### getIntegerCodeForString

```
@UnstableApi
public static int getIntegerCodeForString(String string)
```

Returns the integer equal to the big-endian concatenation of the characters in `string` as bytes. The string must be no more than four characters long.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html string` | A string no more than four characters long. |

### getLocaleLanguageTag

```
@UnstableApi
@InlineMe(replacement = "locale.toLanguageTag()")
public static String [getLocaleLanguageTag](https://developer.android.com/reference/androidx/media3/common/util/Util#getLocaleLanguageTag(java.util.Locale))(Locale locale)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/java/util/Locale.html#toLanguageTag()` instead.

### getMaxPendingFramesCountForMediaCodecDecoders

```
@UnstableApi
public static int getMaxPendingFramesCountForMediaCodecDecoders(Context context)
```

Returns the number of maximum pending output frames that are allowed on a `https://developer.android.com/reference/android/media/MediaCodec.html` decoder.

### getMediaDurationForPlayoutDuration

```
@UnstableApi
public static long getMediaDurationForPlayoutDuration(long playoutDuration, float speed)
```

Returns the duration of media that will elapse in `playoutDuration`.

| Parameters |
|---|---|
| `long playoutDuration` | The duration to scale. |
| `float speed` | The factor by which playback is sped up. |

| Returns |
|---|---|
| `long` | The scaled duration, in the same units as `playoutDuration`. |

### getNowUnixTimeMs

```
@UnstableApi
public static long getNowUnixTimeMs(long elapsedRealtimeEpochOffsetMs)
```

Returns the current time in milliseconds since the epoch.

| Parameters |
|---|---|
| `long elapsedRealtimeEpochOffsetMs` | The offset between `https://developer.android.com/reference/android/os/SystemClock.html#elapsedRealtime()` and the time since the Unix epoch, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if unknown. |

| Returns |
|---|---|
| `long` | The Unix time in milliseconds since the epoch. |

### getPcmEncoding

```
@UnstableApi
@C.PcmEncoding
public static int getPcmEncoding(int bitDepth)
```

Converts a sample bit depth to a corresponding little-endian integer PCM encoding constant.

Value is one of the following:

- `Format.NO_VALUE`

<br />

| Parameters |
|---|---|
| `int bitDepth` | The bit depth. Supported values are 8, 16, 24 and 32. |

| Returns |
|---|---|
| `int` | The corresponding encoding. One of `https://developer.android.com/reference/androidx/media3/common/C#ENCODING_PCM_8BIT()`, `https://developer.android.com/reference/androidx/media3/common/C#ENCODING_PCM_16BIT()`, `https://developer.android.com/reference/androidx/media3/common/C#ENCODING_PCM_24BIT()` and `https://developer.android.com/reference/androidx/media3/common/C#ENCODING_PCM_32BIT()`. If the bit depth is unsupported then `https://developer.android.com/reference/androidx/media3/common/C#ENCODING_INVALID()` is returned. |

### getPcmEncoding

```
@UnstableApi
@C.PcmEncoding
public static int getPcmEncoding(int bitDepth, ByteOrder byteOrder)
```

Converts a sample bit depth and byte order to a corresponding integer PCM encoding constant.

Value is one of the following:

- `Format.NO_VALUE`

<br />

| Parameters |
|---|---|
| `int bitDepth` | The bit depth. Supported values are 8, 16, 24 and 32. |
| `https://developer.android.com/reference/java/nio/ByteOrder.html byteOrder` | The byte order. |

| Returns |
|---|---|
| `int` | The corresponding integer PCM encoding. If the bit depth is unsupported then `https://developer.android.com/reference/androidx/media3/common/C#ENCODING_INVALID()` is returned. |

### getPcmFormat

```
@UnstableApi
public static Format getPcmFormat(AudioProcessor.AudioFormat audioFormat)
```

Gets a PCM `https://developer.android.com/reference/androidx/media3/common/Format` based on the `https://developer.android.com/reference/androidx/media3/common/audio/AudioProcessor.AudioFormat`.

### getPcmFormat

```
@UnstableApi
public static Format getPcmFormat(@C.PcmEncoding int pcmEncoding, int channels, int sampleRate)
```

Gets a PCM `https://developer.android.com/reference/androidx/media3/common/Format` with the specified parameters.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/media3/common/C.PcmEncoding int pcmEncoding` | The `https://developer.android.com/reference/androidx/media3/common/C.PcmEncoding`. Value is one of the following: - `Format.NO_VALUE` <br /> |
| `int channels` | The number of channels, or `https://developer.android.com/reference/androidx/media3/common/Format#NO_VALUE()` if unknown. |
| `int sampleRate` | The sample rate in Hz, or `https://developer.android.com/reference/androidx/media3/common/Format#NO_VALUE()` if unknown. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Format` | The PCM format. |

### getPcmFrameSize

```
@UnstableApi
@Pure
public static int getPcmFrameSize(@C.PcmEncoding int pcmEncoding, int channelCount)
```

Returns the frame size for audio with `channelCount` channels in the specified encoding.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/media3/common/C.PcmEncoding int pcmEncoding` | The encoding of the audio data. Value is one of the following: - `Format.NO_VALUE` <br /> |
| `int channelCount` | The channel count. |

| Returns |
|---|---|
| `int` | The size of one audio frame in bytes. |

### getPlayoutDurationForMediaDuration

```
@UnstableApi
public static long getPlayoutDurationForMediaDuration(long mediaDuration, float speed)
```

Returns the playout duration of `mediaDuration` of media.

| Parameters |
|---|---|
| `long mediaDuration` | The duration to scale. |
| `float speed` | The factor by which playback is sped up. |

| Returns |
|---|---|
| `long` | The scaled duration, in the same units as `mediaDuration`. |

### getRoleFlagStrings

```
@UnstableApi
public static List<String> getRoleFlagStrings(@C.RoleFlags int roleFlags)
```

Returns a list of strings representing the `https://developer.android.com/reference/androidx/media3/common/C.RoleFlags` values present in `
roleFlags`.

### getSelectionFlagStrings

```
@UnstableApi
public static List<String> getSelectionFlagStrings(@C.SelectionFlags int selectionFlags)
```

Returns a list of strings representing the `https://developer.android.com/reference/androidx/media3/common/C.SelectionFlags` values present in `
selectionFlags`.

### getStreamTypeForAudioUsage

```
@UnstableApi
@C.StreamType
public static int [getStreamTypeForAudioUsage](https://developer.android.com/reference/androidx/media3/common/util/Util#getStreamTypeForAudioUsage(int))(@C.AudioUsage int usage)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/media3/common/AudioAttributes#getStreamType()` instead.

### getStringForTime

```
@UnstableApi
public static String getStringForTime(long timeMs)
```

Returns the specified millisecond time formatted as a string.

| Parameters |
|---|---|
| `long timeMs` | The time to format as a string, in milliseconds. |

| Returns |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html` | The time formatted as a string. |

### getStringForTime

```
@UnstableApi
public static String getStringForTime(
    StringBuilder builder,
    Formatter formatter,
    long timeMs
)
```

Returns the specified millisecond time formatted as a string.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/StringBuilder.html builder` | The builder that `formatter` will write to. |
| `https://developer.android.com/reference/java/util/Formatter.html formatter` | The formatter. |
| `long timeMs` | The time to format as a string, in milliseconds. |

| Returns |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html` | The time formatted as a string. |

### getSystemLanguageCodes

```
@UnstableApi
public static String[] getSystemLanguageCodes()
```

Returns a non-empty array of normalized IETF BCP 47 language tags for the system languages ordered by preference.

### getSystemProperty

```
@UnstableApi
public static @Nullable String getSystemProperty(String name)
```

Returns the value of the given system property, or `null` if the property cannot be read or is not set.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html name` | The name of the system property. |

### getTrackTypeString

```
@UnstableApi
public static String getTrackTypeString(@C.TrackType int trackType)
```

Returns a string representation of a `https://developer.android.com/reference/androidx/media3/common/C.TrackType`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/media3/common/C.TrackType int trackType` | A `https://developer.android.com/reference/androidx/media3/common/C.TrackType` constant, |

| Returns |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html` | A string representation of this constant. |

### getUserAgent

```
public static String getUserAgent(Context context, String applicationName)
```

Returns a user agent string based on the given application name and the library version.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/content/Context.html context` | A valid context of the calling application. |
| `https://developer.android.com/reference/java/lang/String.html applicationName` | String that will be prefix'ed to the generated user agent. |

| Returns |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html` | A user agent string generated using the applicationName and the library version. |

### getUtf8Bytes

```
@UnstableApi
public static byte[] getUtf8Bytes(String value)
```

Returns a new byte array containing the code points of a `https://developer.android.com/reference/java/lang/String.html` encoded using UTF-8.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html value` | The `https://developer.android.com/reference/java/lang/String.html` whose bytes should be obtained. |

| Returns |
|---|---|
| `byte[]` | The code points encoding using UTF-8. |

### getVideoCodecFlagForMime

```
@UnstableApi
@C.VideoCodecFlags
public static int getVideoCodecFlagForMime(String mimeType)
```

Returns the `https://developer.android.com/reference/androidx/media3/common/C.VideoCodecFlags` corresponding to the provided MIME type.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | If `mimeType` is not a recognized video codec. |

### gzip

```
@UnstableApi
public static byte[] gzip(byte[] input)
```

Compresses `input` using gzip and returns the result in a newly allocated byte array.

### handlePauseButtonAction

```
public static boolean handlePauseButtonAction(@Nullable Player player)
```

Updates the player to handle an interaction with a pause button.

This method assumes the pause button is enabled if `https://developer.android.com/reference/androidx/media3/common/util/Util#shouldShowPlayButton(androidx.media3.common.Player)` returns `false`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/Player player` | The `https://developer.android.com/reference/androidx/media3/common/Player`. May be `null`. |

| Returns |
|---|---|
| `boolean` | Whether a player method was triggered to handle this action. |

### handlePlayButtonAction

```
public static boolean handlePlayButtonAction(@Nullable Player player)
```

Updates the player to handle an interaction with a play button.

This method assumes the play button is enabled if `https://developer.android.com/reference/androidx/media3/common/util/Util#shouldShowPlayButton(androidx.media3.common.Player)` returns `true`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/Player player` | The `https://developer.android.com/reference/androidx/media3/common/Player`. May be `null`. |

| Returns |
|---|---|
| `boolean` | Whether a player method was triggered to handle this action. |

### handlePlayPauseButtonAction

```
public static boolean handlePlayPauseButtonAction(@Nullable Player player)
```

Updates the player to handle an interaction with a play or pause button.

This method assumes that the UI element enables a play button if `https://developer.android.com/reference/androidx/media3/common/util/Util#shouldShowPlayButton(androidx.media3.common.Player)` returns `true` and a pause button otherwise.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/Player player` | The `https://developer.android.com/reference/androidx/media3/common/Player`. May be `null`. |

| Returns |
|---|---|
| `boolean` | Whether a player method was triggered to handle this action. |

### handlePlayPauseButtonAction

```
@UnstableApi
public static boolean handlePlayPauseButtonAction(
    @Nullable Player player,
    boolean playIfSuppressed
)
```

Updates the player to handle an interaction with a play or pause button.

This method assumes that the UI element enables a play button if `https://developer.android.com/reference/androidx/media3/common/util/Util#shouldShowPlayButton(androidx.media3.common.Player,boolean)` returns `true` and a pause button otherwise.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/Player player` | The `https://developer.android.com/reference/androidx/media3/common/Player`. May be `null`. |
| `boolean playIfSuppressed` | Whether to trigger a play action if playback is `https://developer.android.com/reference/androidx/media3/common/Player#getPlaybackSuppressionReason()`. |

| Returns |
|---|---|
| `boolean` | Whether a player method was triggered to handle this action. |

### ignoreFuture

```
@UnstableApi
public static void <T> ignoreFuture(Future<T> unused)
```

Ignores the future to avoid static code analysis tools to complain.

### inferContentType

```
@UnstableApi
@C.ContentType
public static int [inferContentType](https://developer.android.com/reference/androidx/media3/common/util/Util#inferContentType(java.lang.String))(String fileName)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/android/net/Uri.html#parse(java.lang.String)` and `https://developer.android.com/reference/androidx/media3/common/util/Util#inferContentType(android.net.Uri)` for full file paths or `https://developer.android.com/reference/androidx/media3/common/util/Util#inferContentTypeForExtension(java.lang.String)` for extensions.

### inferContentType

```
@C.ContentType
public static int inferContentType(Uri uri)
```

Makes a best guess to infer the `https://developer.android.com/reference/androidx/media3/common/C.ContentType` from a `https://developer.android.com/reference/android/net/Uri.html`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/net/Uri.html uri` | The `https://developer.android.com/reference/android/net/Uri.html`. |

| Returns |
|---|---|
| `int` | The content type. |

### inferContentType

```
@UnstableApi
@C.ContentType
public static int [inferContentType](https://developer.android.com/reference/androidx/media3/common/util/Util#inferContentType(android.net.Uri,java.lang.String))(Uri uri, @Nullable String overrideExtension)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/media3/common/util/Util#inferContentTypeForExtension(java.lang.String)` when `overrideExtension` is non-empty, and `https://developer.android.com/reference/androidx/media3/common/util/Util#inferContentType(android.net.Uri)` otherwise.

### inferContentTypeForExtension

```
@C.ContentType
public static int inferContentTypeForExtension(String fileExtension)
```

Makes a best guess to infer the `https://developer.android.com/reference/androidx/media3/common/C.ContentType` from a file extension.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html fileExtension` | The extension of the file (excluding the '.'). |

| Returns |
|---|---|
| `int` | The content type. |

### inferContentTypeForUriAndMimeType

```
@C.ContentType
public static int inferContentTypeForUriAndMimeType(Uri uri, @Nullable String mimeType)
```

Makes a best guess to infer the `https://developer.android.com/reference/androidx/media3/common/C.ContentType` from a `https://developer.android.com/reference/android/net/Uri.html` and optional MIME type.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/net/Uri.html uri` | The `https://developer.android.com/reference/android/net/Uri.html`. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html mimeType` | If MIME type, or `null`. |

| Returns |
|---|---|
| `int` | The content type. |

### inflate

```
@UnstableApi
public static boolean inflate(
    ParsableByteArray input,
    ParsableByteArray output,
    @Nullable Inflater inflater
)
```

Uncompresses the data in `input`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/util/ParsableByteArray input` | Wraps the compressed input data. |
| `https://developer.android.com/reference/androidx/media3/common/util/ParsableByteArray output` | Wraps an output buffer to be used to store the uncompressed data. If ` output.data` isn't big enough to hold the uncompressed data, a new array is created. If `true` is returned then the output's position will be set to 0 and its limit will be set to the length of the uncompressed data. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/util/zip/Inflater.html inflater` | If not null, used to uncompressed the input. Otherwise a new `https://developer.android.com/reference/java/util/zip/Inflater.html` is created. |

| Returns |
|---|---|
| `boolean` | Whether the input is uncompressed successfully. |

### intToStringMaxRadix

```
@UnstableApi
public static String intToStringMaxRadix(int i)
```

Returns a string representation of the integer using radix value `https://developer.android.com/reference/java/lang/Character.html#MAX_RADIX`.

| Parameters |
|---|---|
| `int i` | An integer to be converted to String. |

### isAutomotive

```
@UnstableApi
public static boolean isAutomotive(Context context)
```

Returns whether the app is running on an automotive device.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/content/Context.html context` | Any context. |

| Returns |
|---|---|
| `boolean` | Whether the app is running on an automotive device. |

### isBitmapFactorySupportedMimeType

```
@UnstableApi
public static boolean isBitmapFactorySupportedMimeType(String mimeType)
```

Returns the image MIME types that can be decoded and loaded by `https://developer.android.com/reference/android/graphics/BitmapFactory.html` that Media3 aims to support.

### isEncodingHighResolutionPcm

```
@UnstableApi
public static boolean isEncodingHighResolutionPcm(@C.PcmEncoding int encoding)
```

Returns whether `encoding` is high resolution (\> 16-bit) PCM.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/media3/common/C.PcmEncoding int encoding` | The encoding of the audio data. Value is one of the following: - `Format.NO_VALUE` <br /> |

| Returns |
|---|---|
| `boolean` | Whether the encoding is high resolution PCM. |

### isEncodingLinearPcm

```
@UnstableApi
public static boolean isEncodingLinearPcm(@C.Encoding int encoding)
```

Returns whether `encoding` is one of the linear PCM encodings.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/media3/common/C.Encoding int encoding` | The encoding of the audio data. Value is one of the following: - `Format.NO_VALUE` <br /> |

| Returns |
|---|---|
| `boolean` | Whether the encoding is one of the PCM encodings. |

### isFloatPcmEncoding

```
@UnstableApi
public static boolean isFloatPcmEncoding(@C.PcmEncoding int encoding)
```

Returns whether `encoding` is a floating-point PCM encoding.

### isFrameDropAllowedOnSurfaceInput

```
@UnstableApi
public static boolean isFrameDropAllowedOnSurfaceInput(Context context)
```

### isLinebreak

```
@UnstableApi
public static boolean isLinebreak(int c)
```

Returns whether the given character is a carriage return ('\\r') or a line feed ('\\n').

| Parameters |
|---|---|
| `int c` | The character. |

| Returns |
|---|---|
| `boolean` | Whether the given character is a linebreak. |

### isLocalFileUri

```
@UnstableApi
public static boolean isLocalFileUri(Uri uri)
```

Returns true if the URI is a path to a local file or a reference to a local file.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/net/Uri.html uri` | The uri to test. |

### isPcmEncodingBigEndian

```
@UnstableApi
public static boolean isPcmEncodingBigEndian(@C.PcmEncoding int encoding)
```

Returns whether `encoding` is a big-endian PCM encoding.

### isRunningOnEmulator

```
@UnstableApi
public static boolean isRunningOnEmulator()
```

Returns true if the code path is currently running on an emulator.

### isSorted

```
@UnstableApi
public static boolean isSorted(long[] values)
```

Returns whether `values` is sorted in ascending order.

### isTv

```
@UnstableApi
public static boolean isTv(Context context)
```

Returns whether the app is running on a TV device.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/content/Context.html context` | Any context. |

| Returns |
|---|---|
| `boolean` | Whether the app is running on a TV device. |

### isWear

```
@UnstableApi
public static boolean isWear(Context context)
```

Returns whether the app is running on a Wear OS device.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/content/Context.html context` | Any context. |

| Returns |
|---|---|
| `boolean` | Whether the app is running on a Wear OS device. |

### linearSearch

```
@UnstableApi
public static int linearSearch(int[] array, int value)
```

Returns the index of the first occurrence of `value` in `array`, or `https://developer.android.com/reference/androidx/media3/common/C#INDEX_UNSET()` if `value` is not contained in `array`.

| Parameters |
|---|---|
| `int[] array` | The array to search. |
| `int value` | The value to search for. |

| Returns |
|---|---|
| `int` | The index of the first occurrence of value in `array`, or `https://developer.android.com/reference/androidx/media3/common/C#INDEX_UNSET()` if `value` is not contained in `array`. |

### linearSearch

```
@UnstableApi
public static int linearSearch(long[] array, long value)
```

Returns the index of the first occurrence of `value` in `array`, or `https://developer.android.com/reference/androidx/media3/common/C#INDEX_UNSET()` if `value` is not contained in `array`.

| Parameters |
|---|---|
| `long[] array` | The array to search. |
| `long value` | The value to search for. |

| Returns |
|---|---|
| `int` | The index of the first occurrence of value in `array`, or `https://developer.android.com/reference/androidx/media3/common/C#INDEX_UNSET()` if `value` is not contained in `array`. |

### loadAsset

```
@UnstableApi
public static String loadAsset(Context context, String assetPath)
```

Loads a file from the assets folder.

This should only be used for known-small files. Generally, loading assets should be done with `AssetDataSource`.

The file is assumed to be encoded in UTF-8.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/content/Context.html context` | The `https://developer.android.com/reference/android/content/Context.html`. |
| `https://developer.android.com/reference/java/lang/String.html assetPath` | The path to the file to load, from the assets folder. |

| Returns |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html` | The content of the file to load. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | If the file couldn't be read. |

### loadRawResource

```
@UnstableApi
public static String loadRawResource(Context context, int resId)
```

Loads a file from a raw resource.

This should only be used for known-small files.

The file is assumed to be encoded in UTF-8.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/content/Context.html context` | The `https://developer.android.com/reference/android/content/Context.html`. |
| `int resId` | The resource ID of the file to load. |

| Returns |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html` | The content of the file to load. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | If the file couldn't be read. |

### maxValue

```
@UnstableApi
public static long maxValue(SparseLongArray sparseLongArray)
```

Returns the maximum value in the given `https://developer.android.com/reference/android/util/SparseLongArray.html`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/util/SparseLongArray.html sparseLongArray` | The `https://developer.android.com/reference/android/util/SparseLongArray.html`. |

| Returns |
|---|---|
| `long` | The maximum value. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/util/NoSuchElementException.html` | If the array is empty. |

### maybeInflate

```
@UnstableApi
public static boolean maybeInflate(
    ParsableByteArray input,
    ParsableByteArray output,
    @Nullable Inflater inflater
)
```

Uncompresses the data in `input` if it starts with the zlib marker `0x78`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/util/ParsableByteArray input` | Wraps the compressed input data. |
| `https://developer.android.com/reference/androidx/media3/common/util/ParsableByteArray output` | Wraps an output buffer to be used to store the uncompressed data. If ` output.data` isn't big enough to hold the uncompressed data, a new array is created. If `true` is returned then the output's position will be set to 0 and its limit will be set to the length of the uncompressed data. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/util/zip/Inflater.html inflater` | If not null, used to uncompress the input. Otherwise a new `https://developer.android.com/reference/java/util/zip/Inflater.html` is created. |

| Returns |
|---|---|
| `boolean` | Whether the input is uncompressed successfully. |

### maybeRequestReadExternalStoragePermission

```
public static boolean [maybeRequestReadExternalStoragePermission](https://developer.android.com/reference/androidx/media3/common/util/Util#maybeRequestReadExternalStoragePermission(android.app.Activity,androidx.media3.common.MediaItem...))(
    Activity activity,
    MediaItem[] mediaItems
)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/media3/common/util/Util#maybeRequestReadStoragePermission(android.app.Activity,androidx.media3.common.MediaItem...)` instead.

### maybeRequestReadExternalStoragePermission

```
public static boolean [maybeRequestReadExternalStoragePermission](https://developer.android.com/reference/androidx/media3/common/util/Util#maybeRequestReadExternalStoragePermission(android.app.Activity,android.net.Uri...))(
    Activity activity,
    Uri[] uris
)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/media3/common/util/Util#maybeRequestReadStoragePermission(android.app.Activity,androidx.media3.common.MediaItem...)` instead.

### maybeRequestReadStoragePermission

```
public static boolean maybeRequestReadStoragePermission(
    Activity activity,
    MediaItem[] mediaItems
)
```

Checks whether it's necessary to request storage reading permissions for the specified `https://developer.android.com/reference/androidx/media3/common/MediaItem`, requesting the permissions if necessary.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/app/Activity.html activity` | The host activity for checking and requesting the permission. |
| `MediaItem[] mediaItems` | `https://developer.android.com/reference/androidx/media3/common/MediaItem`s that may require storage reading permissions to read. |

| Returns |
|---|---|
| `boolean` | Whether a permission request was made. |

### minValue

```
@UnstableApi
public static long minValue(SparseLongArray sparseLongArray)
```

Returns the minimum value in the given `https://developer.android.com/reference/android/util/SparseLongArray.html`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/util/SparseLongArray.html sparseLongArray` | The `https://developer.android.com/reference/android/util/SparseLongArray.html`. |

| Returns |
|---|---|
| `long` | The minimum value. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/util/NoSuchElementException.html` | If the array is empty. |

### moveItems

```
@UnstableApi
public static void <T extends Object> moveItems(
    List<T> items,
    int fromIndex,
    int toIndex,
    int newFromIndex
)
```

Moves the elements starting at `fromIndex` to `newFromIndex`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/util/List.html<T> items` | The list of which to move elements. |
| `int fromIndex` | The index at which the items to move start. |
| `int toIndex` | The index up to which elements should be moved (exclusive). |
| `int newFromIndex` | The new from index. |

### msToUs

```
@UnstableApi
public static long msToUs(long timeMs)
```

Converts a time in milliseconds to the corresponding time in microseconds, preserving `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` values and `https://developer.android.com/reference/androidx/media3/common/C#TIME_END_OF_SOURCE()` values.

| Parameters |
|---|---|
| `long timeMs` | The time in milliseconds. |

| Returns |
|---|---|
| `long` | The corresponding time in microseconds. |

### newSingleThreadExecutor

```
@UnstableApi
public static ExecutorService newSingleThreadExecutor(String threadName)
```

Instantiates a new single threaded executor whose thread has the specified name.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html threadName` | The name of the thread. |

| Returns |
|---|---|
| `https://developer.android.com/reference/java/util/concurrent/ExecutorService.html` | The executor. |

### newSingleThreadScheduledExecutor

```
@UnstableApi
public static ScheduledExecutorService newSingleThreadScheduledExecutor(String threadName)
```

Instantiates a new single threaded scheduled executor whose thread has the specified name.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html threadName` | The name of the thread. |

| Returns |
|---|---|
| `https://developer.android.com/reference/java/util/concurrent/ScheduledExecutorService.html` | The executor. |

### normalizeLanguageCode

```
@UnstableApi
@PolyNull
public static @PolyNull String normalizeLanguageCode(@PolyNull @PolyNull String language)
```

Returns a normalized IETF BCP 47 language tag for `language`.

| Parameters |
|---|---|
| `@https://checkerframework.org/api/org/checkerframework/checker/nullness/qual/PolyNull.html @https://checkerframework.org/api/org/checkerframework/checker/nullness/qual/PolyNull.html https://developer.android.com/reference/java/lang/String.html language` | A case-insensitive language code supported by `https://developer.android.com/reference/java/util/Locale.html#forLanguageTag(java.lang.String)`. |

| Returns |
|---|---|
| `@https://checkerframework.org/api/org/checkerframework/checker/nullness/qual/PolyNull.html https://developer.android.com/reference/java/lang/String.html` | The all-lowercase normalized code, or null if the input was null, or ` language.toLowerCase()` if the language could not be normalized. |

### nsToMs

```
@UnstableApi
public static long nsToMs(long timeNs)
```

Converts a time in nanoseconds to the corresponding time in milliseconds, preserving `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` and `https://developer.android.com/reference/androidx/media3/common/C#TIME_END_OF_SOURCE()` values.

| Parameters |
|---|---|
| `long timeNs` | The time in nanoseconds. |

| Returns |
|---|---|
| `long` | The corresponding time in milliseconds. |

### nullSafeArrayAppend

```
@UnstableApi
public static T[] <T> nullSafeArrayAppend(T[] original, T newElement)
```

Creates a new array containing `original` with `newElement` appended.

| Parameters |
|---|---|
| `T[] original` | The input array. |
| `T newElement` | The element to append. |

| Returns |
|---|---|
| `T[]` | The new array. |

### nullSafeArrayConcatenation

```
@UnstableApi
public static T[] <T> nullSafeArrayConcatenation(T[] first, T[] second)
```

Creates a new array containing the concatenation of two non-null type arrays.

| Parameters |
|---|---|
| `T[] first` | The first array. |
| `T[] second` | The second array. |

| Returns |
|---|---|
| `T[]` | The concatenated result. |

### nullSafeArrayCopy

```
@UnstableApi
public static T[] <T> nullSafeArrayCopy(T[] input, int length)
```

Copies and optionally truncates an array. Prevents null array elements created by `https://developer.android.com/reference/java/util/Arrays.html#copyOf(T[], int)` by ensuring the new length does not exceed the current length.

| Parameters |
|---|---|
| `T[] input` | The input array. |
| `int length` | The output array length. Must be less or equal to the length of the input array. |

| Returns |
|---|---|
| `T[]` | The copied array. |

### nullSafeArrayCopyOfRange

```
@UnstableApi
public static T[] <T> nullSafeArrayCopyOfRange(T[] input, int from, int to)
```

Copies a subset of an array.

| Parameters |
|---|---|
| `T[] input` | The input array. |
| `int from` | The start the range to be copied, inclusive |
| `int to` | The end of the range to be copied, exclusive. |

| Returns |
|---|---|
| `T[]` | The copied array. |

### nullSafeListToArray

```
@UnstableApi
public static void <T> nullSafeListToArray(List<T> list, T[] array)
```

Copies the contents of `list` into `array`.

`list.size()` must be the same as `array.length` to ensure the contents can be copied into `array` without leaving any nulls at the end.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/util/List.html<T> list` | The list to copy items from. |
| `T[] array` | The array to copy items to. |

### parseXsDateTime

```
@UnstableApi
public static long parseXsDateTime(String value)
```

Parses an xs:dateTime attribute value, returning the parsed timestamp in milliseconds since the epoch.

The parsing implemented here is deliberately more tolerant than the [XML spec](https://www.w3.org/TR/xmlschema-2/#dateTime) allows, as this method is also used to parse ISO 8601 and RFC 3339 date-time strings.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html value` | The attribute value to decode. |

| Returns |
|---|---|
| `long` | The parsed timestamp in milliseconds since the epoch. |

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/ParserException` | if an error occurs parsing the dateTime attribute value. |

### parseXsDuration

```
@UnstableApi
public static long parseXsDuration(String value)
```

Parses an xs:duration attribute value, returning the parsed duration in milliseconds.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html value` | The attribute value to decode. |

| Returns |
|---|---|
| `long` | The parsed duration in milliseconds. |

### percentFloat

```
@UnstableApi
public static float percentFloat(long numerator, long denominator)
```

Returns the floating point percentage of `numerator` divided by `denominator`. Note that this may return `https://developer.android.com/reference/java/lang/Float.html#POSITIVE_INFINITY`, `https://developer.android.com/reference/java/lang/Float.html#NEGATIVE_INFINITY` or `https://developer.android.com/reference/java/lang/Float.html#NaN` if the denominator is zero.

### percentInt

```
@UnstableApi
public static int percentInt(long numerator, long denominator)
```

Returns the integer percentage of `numerator` divided by `denominator`. This uses integer arithmetic (round down).

The result is cast from `long` to `int` following the rules of `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/primitives/Ints.html#saturatedCast(long)`.

### postOrRun

```
@UnstableApi
public static boolean postOrRun(Handler handler, Runnable runnable)
```

Posts the `https://developer.android.com/reference/java/lang/Runnable.html` if the calling thread differs with the `https://developer.android.com/reference/android/os/Looper.html` of the `https://developer.android.com/reference/android/os/Handler.html`. Otherwise, runs the `https://developer.android.com/reference/java/lang/Runnable.html` directly.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/os/Handler.html handler` | The handler to which the `https://developer.android.com/reference/java/lang/Runnable.html` will be posted. |
| `https://developer.android.com/reference/java/lang/Runnable.html runnable` | The runnable to either post or run. |

| Returns |
|---|---|
| `boolean` | `true` if the `https://developer.android.com/reference/java/lang/Runnable.html` was successfully posted to the `https://developer.android.com/reference/android/os/Handler.html` or run. `false` otherwise. |

### postOrRun

```
@UnstableApi
public static boolean postOrRun(HandlerWrapper handler, Runnable runnable)
```

Posts the `https://developer.android.com/reference/java/lang/Runnable.html` if the calling thread differs with the `https://developer.android.com/reference/android/os/Looper.html` of the `https://developer.android.com/reference/androidx/media3/common/util/HandlerWrapper`. Otherwise, runs the `https://developer.android.com/reference/java/lang/Runnable.html` directly.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/util/HandlerWrapper handler` | The `https://developer.android.com/reference/androidx/media3/common/util/HandlerWrapper` to which the `https://developer.android.com/reference/java/lang/Runnable.html` will be posted. |
| `https://developer.android.com/reference/java/lang/Runnable.html runnable` | The runnable to either post or run. |

| Returns |
|---|---|
| `boolean` | `true` if the `https://developer.android.com/reference/java/lang/Runnable.html` was successfully posted to the `https://developer.android.com/reference/androidx/media3/common/util/HandlerWrapper` or run. `false` otherwise. |

### postOrRunWithCompletion

```
@UnstableApi
public static ListenableFuture<T> <T> postOrRunWithCompletion(
    Handler handler,
    Runnable runnable,
    T successValue
)
```

Posts the `https://developer.android.com/reference/java/lang/Runnable.html` if the calling thread differs with the `https://developer.android.com/reference/android/os/Looper.html` of the `https://developer.android.com/reference/android/os/Handler.html`. Otherwise, runs the `https://developer.android.com/reference/java/lang/Runnable.html` directly. Also returns a `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html` for when the `https://developer.android.com/reference/java/lang/Runnable.html` has run.

| Parameters |
|---|---|
| `<T>` | The type of `successValue`. |
| `https://developer.android.com/reference/android/os/Handler.html handler` | The handler to which the `https://developer.android.com/reference/java/lang/Runnable.html` will be posted. |
| `https://developer.android.com/reference/java/lang/Runnable.html runnable` | The runnable to either post or run. |
| `T successValue` | The value to set in the `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html` once the runnable completes. |

| Returns |
|---|---|
| `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<T>` | A `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html` for when the `https://developer.android.com/reference/java/lang/Runnable.html` has run. |

### putInt24

```
@UnstableApi
public static void putInt24(ByteBuffer buffer, int value)
```

Writes a 24-bit integer value to a buffer at its current `https://developer.android.com/reference/java/nio/Buffer.html#position()`.

This is a relative operation that affects the buffer's position.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/nio/ByteBuffer.html buffer` | The buffer on which to write the integer. |
| `int value` | The integer value to write. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | If `value` is out of range for a 24-bit integer. |

### readBoolean

```
@UnstableApi
public static boolean readBoolean(Parcel parcel)
```

Reads an integer from a `https://developer.android.com/reference/android/os/Parcel.html` and interprets it as a boolean, with 0 mapping to false and all other values mapping to true.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/os/Parcel.html parcel` | The `https://developer.android.com/reference/android/os/Parcel.html` to read from. |

| Returns |
|---|---|
| `boolean` | The read value. |

### recursiveDelete

```
@UnstableApi
public static void recursiveDelete(File fileOrDirectory)
```

Recursively deletes a directory and its content.

### registerReceiverNotExported

```
@UnstableApi
public static @Nullable Intent registerReceiverNotExported(
    Context context,
    @Nullable BroadcastReceiver receiver,
    IntentFilter filter
)
```

Registers a `https://developer.android.com/reference/android/content/BroadcastReceiver.html` that's not intended to receive broadcasts from other apps. This will be enforced by specifying `https://developer.android.com/reference/android/content/Context.html#RECEIVER_NOT_EXPORTED` if `https://developer.android.com/reference/android/os/Build.VERSION.html#SDK_INT` is 33 or above.

Do not use this method if registering a receiver for a [protected system broadcast](https://android.googlesource.com/platform/frameworks/base/+/master/core/res/AndroidManifest.xml).

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/content/BroadcastReceiver.html receiver` | The `https://developer.android.com/reference/android/content/BroadcastReceiver.html` to register. This value may be null. |
| `https://developer.android.com/reference/android/content/Context.html context` | The context on which `https://developer.android.com/reference/android/content/Context.html#registerReceiver(android.content.BroadcastReceiver, android.content.IntentFilter)` will be called. |
| `https://developer.android.com/reference/android/content/IntentFilter.html filter` | Selects the Intent broadcasts to be received. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/content/Intent.html` | The first sticky intent found that matches `filter`, or null if there are none. |

### removeRange

```
@UnstableApi
public static void <T> removeRange(List<T> list, int fromIndex, int toIndex)
```

Removes an indexed range from a List.

Does nothing if the provided range is valid and `fromIndex == toIndex`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/util/List.html<T> list` | The List to remove the range from. |
| `int fromIndex` | The first index to be removed (inclusive). |
| `int toIndex` | The last index to be removed (exclusive). |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | If `fromIndex`\<0, `toIndex`\>` list.size()`, or `fromIndex`\>`toIndex`. |

### sampleCountToDurationUs

```
@UnstableApi
@Pure
public static long sampleCountToDurationUs(long sampleCount, int sampleRate)
```

Returns the total duration (in microseconds) of `sampleCount` samples of equal duration at `sampleRate`.

If `sampleRate` is less than `https://developer.android.com/reference/androidx/media3/common/C#MICROS_PER_SECOND()`, the duration produced by this method can be reversed to the original sample count using `https://developer.android.com/reference/androidx/media3/common/util/Util#durationUsToSampleCount(long,int)`.

| Parameters |
|---|---|
| `long sampleCount` | The number of samples. |
| `int sampleRate` | The sample rate, in samples per second. |

| Returns |
|---|---|
| `long` | The total duration, in microseconds, of `sampleCount` samples. |

### scaleLargeTimestamp

```
@UnstableApi
public static long scaleLargeTimestamp(long timestamp, long multiplier, long divisor)
```

Scales a large timestamp.

Equivalent to `https://developer.android.com/reference/androidx/media3/common/util/Util#scaleLargeValue(long,long,long,java.math.RoundingMode)` with `https://developer.android.com/reference/java/math/RoundingMode.html#DOWN`.

| Parameters |
|---|---|
| `long timestamp` | The timestamp to scale. |
| `long multiplier` | The multiplier. |
| `long divisor` | The divisor. |

| Returns |
|---|---|
| `long` | The scaled timestamp. |

### scaleLargeTimestamps

```
@UnstableApi
public static long[] scaleLargeTimestamps(
    List<Long> timestamps,
    long multiplier,
    long divisor
)
```

Applies `https://developer.android.com/reference/androidx/media3/common/util/Util#scaleLargeTimestamp(long,long,long)` to a list of unscaled timestamps.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/java/lang/Long.html> timestamps` | The timestamps to scale. |
| `long multiplier` | The multiplier. |
| `long divisor` | The divisor. |

| Returns |
|---|---|
| `long[]` | The scaled timestamps. |

### scaleLargeTimestampsInPlace

```
@UnstableApi
public static void scaleLargeTimestampsInPlace(
    long[] timestamps,
    long multiplier,
    long divisor
)
```

Applies `https://developer.android.com/reference/androidx/media3/common/util/Util#scaleLargeTimestamp(long,long,long)` to an array of unscaled timestamps.

| Parameters |
|---|---|
| `long[] timestamps` | The timestamps to scale. |
| `long multiplier` | The multiplier. |
| `long divisor` | The divisor. |

### scaleLargeValue

```
@UnstableApi
public static long scaleLargeValue(
    long value,
    long multiplier,
    long divisor,
    RoundingMode roundingMode
)
```

Scales a large value by a multiplier and a divisor.

The order of operations in this implementation is designed to minimize the probability of overflow. The implementation tries to stay in integer arithmetic as long as possible, but falls through to floating-point arithmetic if the values can't be combined without overflowing signed 64-bit longs.

If the mathematical result would overflow or underflow a 64-bit long, the result will be either `https://developer.android.com/reference/java/lang/Long.html#MAX_VALUE` or `https://developer.android.com/reference/java/lang/Long.html#MIN_VALUE`, respectively.

| Parameters |
|---|---|
| `long value` | The value to scale. |
| `long multiplier` | The multiplier. |
| `long divisor` | The divisor. |
| `https://developer.android.com/reference/java/math/RoundingMode.html roundingMode` | The rounding mode to use if the result of the division is not an integer. |

| Returns |
|---|---|
| `long` | The scaled value. |

### scaleLargeValues

```
@UnstableApi
public static long[] scaleLargeValues(
    List<Long> values,
    long multiplier,
    long divisor,
    RoundingMode roundingMode
)
```

Applies `https://developer.android.com/reference/androidx/media3/common/util/Util#scaleLargeValue(long,long,long,java.math.RoundingMode)` to a list of unscaled values.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/java/lang/Long.html> values` | The values to scale. |
| `long multiplier` | The multiplier. |
| `long divisor` | The divisor. |
| `https://developer.android.com/reference/java/math/RoundingMode.html roundingMode` | The rounding mode to use if the result of the division is not an integer. |

| Returns |
|---|---|
| `long[]` | The scaled values. |

### scaleLargeValuesInPlace

```
@UnstableApi
public static void scaleLargeValuesInPlace(
    long[] values,
    long multiplier,
    long divisor,
    RoundingMode roundingMode
)
```

Applies `https://developer.android.com/reference/androidx/media3/common/util/Util#scaleLargeValue(long,long,long,java.math.RoundingMode)` to an array of unscaled values.

| Parameters |
|---|---|
| `long[] values` | The values to scale. |
| `long multiplier` | The multiplier. |
| `long divisor` | The divisor. |
| `https://developer.android.com/reference/java/math/RoundingMode.html roundingMode` | The rounding mode to use if the result of the division is not an integer. |

### setForegroundServiceNotification

```
@UnstableApi
public static void setForegroundServiceNotification(
    Service service,
    int notificationId,
    Notification notification,
    int foregroundServiceType,
    String foregroundServiceManifestType
)
```

Sets the notification required for a foreground service.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/app/Service.html service` | The foreground `https://developer.android.com/reference/android/app/Service.html`. |
| `int notificationId` | The notification id. |
| `https://developer.android.com/reference/android/app/Notification.html notification` | The `https://developer.android.com/reference/android/app/Notification.html`. |
| `int foregroundServiceType` | The foreground service type defined in `https://developer.android.com/reference/android/content/pm/ServiceInfo.html`. |
| `https://developer.android.com/reference/java/lang/String.html foregroundServiceManifestType` | The required foreground service type string for the ` <service>` element in the manifest. |

### shouldEnablePlayPauseButton

```
@EnsuresNonNullIf(result = true, expression = "#1")
@UnstableApi
public static boolean shouldEnablePlayPauseButton(@Nullable Player player)
```

Returns whether a play-pause button should be enabled or not.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/Player player` | The `https://developer.android.com/reference/androidx/media3/common/Player`. May be `null`. |

### shouldShowPlayButton

```
@EnsuresNonNullIf(result = false, expression = "#1")
public static boolean shouldShowPlayButton(@Nullable Player player)
```

Returns whether a play button should be presented on a UI element for playback control. If `false`, a pause button should be shown instead.

Use `https://developer.android.com/reference/androidx/media3/common/util/Util#handlePlayPauseButtonAction(androidx.media3.common.Player)`, `https://developer.android.com/reference/androidx/media3/common/util/Util#handlePlayButtonAction(androidx.media3.common.Player)` or `https://developer.android.com/reference/androidx/media3/common/util/Util#handlePauseButtonAction(androidx.media3.common.Player)` to handle the interaction with the play or pause button UI element.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/Player player` | The `https://developer.android.com/reference/androidx/media3/common/Player`. May be `null`. |

### shouldShowPlayButton

```
@UnstableApi
@EnsuresNonNullIf(result = false, expression = "#1")
public static boolean shouldShowPlayButton(
    @Nullable Player player,
    boolean shouldShowPlayIfSuppressed
)
```

Returns whether a play button should be presented on a UI element for playback control. If `false`, a pause button should be shown instead.

Use `https://developer.android.com/reference/androidx/media3/common/util/Util#handlePlayPauseButtonAction(androidx.media3.common.Player)`, `https://developer.android.com/reference/androidx/media3/common/util/Util#handlePlayButtonAction(androidx.media3.common.Player)` or `https://developer.android.com/reference/androidx/media3/common/util/Util#handlePauseButtonAction(androidx.media3.common.Player)` to handle the interaction with the play or pause button UI element.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/Player player` | The `https://developer.android.com/reference/androidx/media3/common/Player`. May be `null`. |
| `boolean shouldShowPlayIfSuppressed` | Whether to show a play button if playback is `https://developer.android.com/reference/androidx/media3/common/Player#getPlaybackSuppressionReason()`. |

### sneakyThrow

```
@UnstableApi
public static void sneakyThrow(Throwable t)
```

A hacky method that always throws `t` even if `t` is a checked exception, and is not declared to be thrown.

### split

```
@UnstableApi
public static String[] split(String value, String regex)
```

Splits a string using `value.split(regex, -1`). Note: this is similar to `https://developer.android.com/reference/java/lang/String.html#split(java.lang.String)` but empty matches at the end of the string will not be omitted from the returned array.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html value` | The string to split. |
| `https://developer.android.com/reference/java/lang/String.html regex` | A delimiting regular expression. |

| Returns |
|---|---|
| `String[]` | The array of strings resulting from splitting the string. |

### splitAtFirst

```
@UnstableApi
public static String[] splitAtFirst(String value, String regex)
```

Splits the string at the first occurrence of the delimiter `regex`. If the delimiter does not match, returns an array with one element which is the input string. If the delimiter does match, returns an array with the portion of the string before the delimiter and the rest of the string.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html value` | The string. |
| `https://developer.android.com/reference/java/lang/String.html regex` | A delimiting regular expression. |

| Returns |
|---|---|
| `String[]` | The string split by the first occurrence of the delimiter. |

### splitCodecs

```
@UnstableApi
public static String[] splitCodecs(@Nullable String codecs)
```

Splits a codecs sequence string, as defined in RFC 6381, into individual codec strings.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html codecs` | A codec sequence string, as defined in RFC 6381. |

| Returns |
|---|---|
| `String[]` | The split codecs, or an array of length zero if the input was empty or null. |

### startForegroundService

```
@UnstableApi
public static @Nullable ComponentName startForegroundService(Context context, Intent intent)
```

Calls `https://developer.android.com/reference/android/content/Context.html#startForegroundService(android.content.Intent)` if `https://developer.android.com/reference/android/os/Build.VERSION.html#SDK_INT` is 26 or higher, or `https://developer.android.com/reference/android/content/Context.html#startService(android.content.Intent)` otherwise.

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/content/Context.html context` | The context to call. |
| `https://developer.android.com/reference/android/content/Intent.html intent` | The intent to pass to the called method. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/content/ComponentName.html` | The result of the called method. |

### stopForeground

```
@UnstableApi
@InlineMe(replacement = "service.stopForeground(removeNotification ? STOP_FOREGROUND_REMOVE :"
              + " STOP_FOREGROUND_DETACH)", staticImports = [""android.app.Service.STOP_FOREGROUND_DETACH"", ""android.app.Service.STOP_FOREGROUND_REMOVE""])
public static void [stopForeground](https://developer.android.com/reference/androidx/media3/common/util/Util#stopForeground(android.app.Service,boolean))(Service service, boolean removeNotification)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/android/app/Service.html#stopForeground(int)` instead.

### subtractWithOverflowDefault

```
@UnstableApi
public static long subtractWithOverflowDefault(long x, long y, long overflowResult)
```

Returns the difference between two arguments, or a third argument if the result overflows.

| Parameters |
|---|---|
| `long x` | The first value. |
| `long y` | The second value. |
| `long overflowResult` | The return value if `x - y` overflows. |

| Returns |
|---|---|
| `long` | `x - y`, or `overflowResult` if the result overflows. |

### sum

```
@UnstableApi
public static long sum(long[] summands)
```

Returns the sum of all summands of the given array.

| Parameters |
|---|---|
| `long[] summands` | The summands to calculate the sum from. |

| Returns |
|---|---|
| `long` | The sum of all summands. |

### tableExists

```
@UnstableApi
public static boolean tableExists(SQLiteDatabase database, String tableName)
```

Returns whether the table exists in the database.

### toByteArray

```
@UnstableApi
public static byte[] [toByteArray](https://developer.android.com/reference/androidx/media3/common/util/Util#toByteArray(java.io.InputStream))(InputStream inputStream)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use Guava's `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/io/ByteStreams.html#toByteArray(java.io.InputStream)` instead.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` |   |

### toByteArray

```
@UnstableApi
public static byte[] toByteArray(float value)
```

Converts a float into an equivalent byte array.

### toByteArray

```
@UnstableApi
public static byte[] toByteArray(int value)
```

Converts a single integer into an equivalent 4-byte array in big-endian order.

### toByteArray

```
@UnstableApi
public static byte[] toByteArray(int[] values)
```

Converts an array of integers into an equivalent byte array.

Each integer is converted into 4 sequential bytes.

For a single integer, prefer Guava's `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/primitives/Ints.html#toByteArray(int)` implementation.

### toFourccString

```
@UnstableApi
public static String toFourccString(int fourcc)
```

### toHexString

```
@UnstableApi
public static String toHexString(byte[] bytes)
```

Returns a string containing a lower-case hex representation of the bytes provided.

| Parameters |
|---|---|
| `byte[] bytes` | The byte data to convert to hex. |

| Returns |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html` | A String containing the hex representation of `bytes`. |

### toHexString

```
@UnstableApi
public static String toHexString(byte[] bytes, int offset, int length)
```

Returns a string containing a lower-case hex representation of the bytes provided.

| Parameters |
|---|---|
| `byte[] bytes` | The byte data to convert to hex. |
| `int offset` | The offset into data to read from. |
| `int length` | The number of bytes to read from data. |

| Returns |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html` | A String containing the hex representation of `bytes` (considering `offset` and `length`). |

### toLong

```
@UnstableApi
public static long toLong(int mostSignificantBits, int leastSignificantBits)
```

Returns the long that is composed of the bits of the 2 specified integers.

| Parameters |
|---|---|
| `int mostSignificantBits` | The 32 most significant bits of the long to return. |
| `int leastSignificantBits` | The 32 least significant bits of the long to return. |

| Returns |
|---|---|
| `long` | a long where its 32 most significant bits are `mostSignificantBits` bits and its 32 least significant bits are `leastSignificantBits`. |

### toUnsignedInt

```
@UnstableApi
public static int toUnsignedInt(long x)
```

Converts a long to an int, checking that the long value fits within the range of an unsigned 32-bit integer.

| Parameters |
|---|---|
| `long x` | The long value to convert. |

| Returns |
|---|---|
| `int` | The integer result. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if `x` is greater than the maximum value of an unsigned 32-bit integer (2\^32 - 1). |

### toUnsignedLong

```
@UnstableApi
public static long toUnsignedLong(int x)
```

Converts an integer to a long by unsigned conversion.

This method is equivalent to `https://developer.android.com/reference/java/lang/Integer.html#toUnsignedLong(int)` for API 26+.

### transformFutureAsync

```
@UnstableApi
public static ListenableFuture<T> <T extends Object, U extends Object> transformFutureAsync(
    ListenableFuture<U> future,
    AsyncFunction<U, T> transformFunction
)
```

Asynchronously transforms the result of a `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html`.

The transformation function is called using a `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/MoreExecutors.html#directExecutor()`.

The returned Future attempts to keep its cancellation state in sync with that of the input future and that of the future returned by the transform function. That is, if the returned Future is cancelled, it will attempt to cancel the other two, and if either of the other two is cancelled, the returned Future will also be cancelled. All forwarded cancellations will not attempt to interrupt.

| Parameters |
|---|---|
| `<T extends https://developer.android.com/reference/java/lang/Object.html>` | The result type of the input future. |
| `<U extends https://developer.android.com/reference/java/lang/Object.html>` | The result type of the transformation function. |
| `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<U> future` | The input `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html`. |
| `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/AsyncFunction.html<U, T> transformFunction` | The function transforming the result of the input future. |

| Returns |
|---|---|
| `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<T>` | A `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html` for the transformed result. |

### unescapeFileName

```
@UnstableApi
public static @Nullable String unescapeFileName(String fileName)
```

Unescapes an escaped file or directory name back to its original value.

See `https://developer.android.com/reference/androidx/media3/common/util/Util#escapeFileName(java.lang.String)` for more information.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/lang/String.html fileName` | File name to be unescaped. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html` | The original value of the file name before it was escaped, or null if the escaped fileName seems invalid. |

### usToMs

```
@UnstableApi
public static long usToMs(long timeUs)
```

Converts a time in microseconds to the corresponding time in milliseconds, preserving `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` and `https://developer.android.com/reference/androidx/media3/common/C#TIME_END_OF_SOURCE()` values.

| Parameters |
|---|---|
| `long timeUs` | The time in microseconds. |

| Returns |
|---|---|
| `long` | The corresponding time in milliseconds. |

### writeBoolean

```
@UnstableApi
public static void writeBoolean(Parcel parcel, boolean value)
```

Writes a boolean to a `https://developer.android.com/reference/android/os/Parcel.html`. The boolean is written as an integer with value 1 (true) or 0 (false).

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/os/Parcel.html parcel` | The `https://developer.android.com/reference/android/os/Parcel.html` to write to. |
| `boolean value` | The value to write. |