# MediaBrowser.MediaItem

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# MediaItem

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/media/browse/MediaBrowser.MediaItem "View this page in Java")  

```
class MediaItem : Parcelable
```

|---|--------------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                             ||
| ↳ | [android.media.browse.MediaBrowser.MediaItem](https://developer.android.com/reference/kotlin/android/media/browse/MediaBrowser.MediaItem#) |

A class with information on a single media item for use in browsing/searching media. MediaItems are application dependent so we cannot guarantee that they contain the right values.

## Summary

|                                                                                                                                    Constants                                                                                                                                    ||
|----------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| static[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [FLAG_BROWSABLE](https://developer.android.com/reference/kotlin/android/media/browse/MediaBrowser.MediaItem#FLAG_BROWSABLE:kotlin.Int) Flag: Indicates that the item has children of its own. |
| static[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [FLAG_PLAYABLE](https://developer.android.com/reference/kotlin/android/media/browse/MediaBrowser.MediaItem#FLAG_PLAYABLE:kotlin.Int) Flag: Indicates that the item is playable.               |

| Inherited constants ||
|---|---|
| From class[Parcelable](https://developer.android.com/reference/kotlin/android/os/Parcelable.html#) |----------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [CONTENTS_FILE_DESCRIPTOR](https://developer.android.com/reference/kotlin/android/os/Parcelable.html#CONTENTS_FILE_DESCRIPTOR:kotlin.Int) <br /> Descriptor bit used with[describeContents()](https://developer.android.com/reference/kotlin/android/os/Parcelable.html#describeContents()): indicates that the Parcelable object's flattened representation includes a file descriptor. <br />                                                                                                                                                                                                        | | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [PARCELABLE_WRITE_RETURN_VALUE](https://developer.android.com/reference/kotlin/android/os/Parcelable.html#PARCELABLE_WRITE_RETURN_VALUE:kotlin.Int) <br /> Flag for use with[writeToParcel](https://developer.android.com/reference/kotlin/android/os/Parcelable.html#writeToParcel(android.os.Parcel,%20kotlin.Int)): the object being written is a return value, that is the result of a function such as "`Parcelable someFunction()`", "`void someFunction(out Parcelable)`", or "`void someFunction(inout Parcelable)`". Some implementations may want to release resources at this point. <br /> | ||

|                                                                                                                                                                                                           Public constructors                                                                                                                                                                                                           ||
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [MediaItem](https://developer.android.com/reference/kotlin/android/media/browse/MediaBrowser.MediaItem#MediaItem(android.media.MediaDescription,%20kotlin.Int))`(`description:` `[MediaDescription](https://developer.android.com/reference/kotlin/android/media/MediaDescription.html#)`, `flags:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Create a new MediaItem for use in browsing media. |

|                                                                                                                                                                                                                           Public methods                                                                                                                                                                                                                           ||
|-------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| open[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)                              | [describeContents](https://developer.android.com/reference/kotlin/android/media/browse/MediaBrowser.MediaItem#describeContents())`()` <br />                                                                                                                                                                                                          |
| open[MediaDescription](https://developer.android.com/reference/kotlin/android/media/MediaDescription.html#) | [getDescription](https://developer.android.com/reference/kotlin/android/media/browse/MediaBrowser.MediaItem#getDescription())`()` Returns the description of the media.                                                                                                                                                                               |
| open[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)                              | [getFlags](https://developer.android.com/reference/kotlin/android/media/browse/MediaBrowser.MediaItem#getFlags())`()` Gets the flags of the item.                                                                                                                                                                                                     |
| open[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)?                       | [getMediaId](https://developer.android.com/reference/kotlin/android/media/browse/MediaBrowser.MediaItem#getMediaId())`()` Returns the media id in the[MediaDescription](https://developer.android.com/reference/kotlin/android/media/MediaDescription.html#)for this item.                                                                            |
| open[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)                      | [isBrowsable](https://developer.android.com/reference/kotlin/android/media/browse/MediaBrowser.MediaItem#isBrowsable())`()` Returns whether this item is browsable.                                                                                                                                                                                   |
| open[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)                      | [isPlayable](https://developer.android.com/reference/kotlin/android/media/browse/MediaBrowser.MediaItem#isPlayable())`()` Returns whether this item is playable.                                                                                                                                                                                      |
| open[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)                        | [toString](https://developer.android.com/reference/kotlin/android/media/browse/MediaBrowser.MediaItem#toString())`()` <br />                                                                                                                                                                                                                          |
| open[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)                            | [writeToParcel](https://developer.android.com/reference/kotlin/android/media/browse/MediaBrowser.MediaItem#writeToParcel(android.os.Parcel,%20kotlin.Int))`(`out:` `[Parcel](https://developer.android.com/reference/kotlin/android/os/Parcel.html#)`, `flags:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` <br /> |

|                                                                                                                                                                                          Properties                                                                                                                                                                                          ||
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------|
| static[Parcelable.Creator](https://developer.android.com/reference/kotlin/android/os/Parcelable.Creator.html#)\<[MediaBrowser.MediaItem](https://developer.android.com/reference/kotlin/android/media/browse/MediaBrowser.MediaItem#)!\> | [CREATOR](https://developer.android.com/reference/kotlin/android/media/browse/MediaBrowser.MediaItem#CREATOR:android.os.Parcelable.Creator) <br /> |

## Constants

### FLAG_BROWSABLE

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val FLAG_BROWSABLE: Int
```

Flag: Indicates that the item has children of its own.  

    Value: 1

### FLAG_PLAYABLE

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val FLAG_PLAYABLE: Int
```

Flag: Indicates that the item is playable.

The id of this item may be passed to[#playFromMediaId(String, Bundle)](https://developer.android.com/reference/kotlin/android/media/session/MediaController.TransportControls.html#)to start playing it.  

    Value: 2

## Public constructors

### MediaItem

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
MediaItem(
    description: MediaDescription, 
    flags: Int)
```

Create a new MediaItem for use in browsing media.

|                                                                                                                                                                                                                                                           Parameters                                                                                                                                                                                                                                                            ||
|---------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `description` | [MediaDescription](https://developer.android.com/reference/kotlin/android/media/MediaDescription.html#):The description of the media, which must include a media id. This value cannot be`null`.                                                                                                                                                                                                                                                                                                                 |
| `flags`       | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):The flags for this item. Value is either`0`or a combination of[android.media.browse.MediaBrowser.MediaItem#FLAG_BROWSABLE](https://developer.android.com/reference/kotlin/android/media/browse/MediaBrowser.MediaItem#FLAG_BROWSABLE:kotlin.Int), and[android.media.browse.MediaBrowser.MediaItem#FLAG_PLAYABLE](https://developer.android.com/reference/kotlin/android/media/browse/MediaBrowser.MediaItem#FLAG_PLAYABLE:kotlin.Int) |

## Public methods

### describeContents

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun describeContents(): Int
```

|                                                                                                                                                                               Return                                                                                                                                                                               ||
|----------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either`0`or[android.os.Parcelable#CONTENTS_FILE_DESCRIPTOR](https://developer.android.com/reference/kotlin/android/os/Parcelable.html#CONTENTS_FILE_DESCRIPTOR:kotlin.Int) |

### getDescription

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun getDescription(): MediaDescription
```

Returns the description of the media.

|                                                                Return                                                                ||
|---------------------------------------------------------------------------------------------------------|-----------------------------|
| [MediaDescription](https://developer.android.com/reference/kotlin/android/media/MediaDescription.html#) | This value cannot be`null`. |

### getFlags

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun getFlags(): Int
```

Gets the flags of the item.

|                                                                                                                                                                                                                                          Return                                                                                                                                                                                                                                          ||
|----------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | Value is either`0`or a combination of[android.media.browse.MediaBrowser.MediaItem#FLAG_BROWSABLE](https://developer.android.com/reference/kotlin/android/media/browse/MediaBrowser.MediaItem#FLAG_BROWSABLE:kotlin.Int), and[android.media.browse.MediaBrowser.MediaItem#FLAG_PLAYABLE](https://developer.android.com/reference/kotlin/android/media/browse/MediaBrowser.MediaItem#FLAG_PLAYABLE:kotlin.Int) |

### getMediaId

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun getMediaId(): String?
```

Returns the media id in the[MediaDescription](https://developer.android.com/reference/kotlin/android/media/MediaDescription.html#)for this item.

|                                                   Return                                                    ||
|-----------------------------------------------------------------------------------|--------------------------|
| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)? | This value may be`null`. |

**See Also**

- [android.media.MediaMetadata#METADATA_KEY_MEDIA_ID](https://developer.android.com/reference/kotlin/android/media/MediaMetadata.html#METADATA_KEY_MEDIA_ID:kotlin.String)  

### isBrowsable

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun isBrowsable(): Boolean
```

Returns whether this item is browsable.  
**See Also**

- [#FLAG_BROWSABLE](https://developer.android.com/reference/kotlin/android/media/browse/MediaBrowser.MediaItem#FLAG_BROWSABLE:kotlin.Int)  

### isPlayable

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun isPlayable(): Boolean
```

Returns whether this item is playable.  
**See Also**

- [#FLAG_PLAYABLE](https://developer.android.com/reference/kotlin/android/media/browse/MediaBrowser.MediaItem#FLAG_PLAYABLE:kotlin.Int)  

### toString

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun toString(): String
```

|                                                          Return                                                          ||
|----------------------------------------------------------------------------------|----------------------------------------|
| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | a string representation of the object. |

### writeToParcel

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun writeToParcel(
    out: Parcel, 
    flags: Int
): Unit
```

|                                                                                                                                                                                                                                                                                     Parameters                                                                                                                                                                                                                                                                                     ||
|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `dest`  | The Parcel in which the object should be written. This value cannot be`null`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `flags` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):Additional flags about how the object should be written. May be 0 or[PARCELABLE_WRITE_RETURN_VALUE](https://developer.android.com/reference/kotlin/android/os/Parcelable.html#PARCELABLE_WRITE_RETURN_VALUE:kotlin.Int). Value is either`0`or a combination of[android.os.Parcelable#PARCELABLE_WRITE_RETURN_VALUE](https://developer.android.com/reference/kotlin/android/os/Parcelable.html#PARCELABLE_WRITE_RETURN_VALUE:kotlin.Int), and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES |

## Properties

### CREATOR

Added in[API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
static val CREATOR: Parcelable.Creator<MediaBrowser.MediaItem!>
```