# GCKMediaQueueItem Class

[Instance Methods](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_media_queue_item#pub-methods) \| [Properties](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_media_queue_item#properties) GCKMediaQueueItem Class Reference

## Overview

A class representing a media queue item.

Instances of this object are immutable.

This class is used in two-way communication between a sender application and a receiver application. The sender constructs them to load or insert a list of media items on the receiver application. The [GCKMediaStatus](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_media_status) from the receiver also contains the list of items represented as instances of this class.

Once loaded, the receiver will assign a unique item ID to each [GCKMediaQueueItem](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_media_queue_item "A class representing a media queue item. "), even if the same media gets loaded multiple times.

Inherits NSObject. Implements \<NSCopying\>.

|---|---|
| ## Instance Method Summary ||
| (instancetype) | - [initWithMediaInformation:autoplay:startTime:preloadTime:activeTrackIDs:customData:](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_media_queue_item#ab0f62ba953a7af951e5328ac9b8b5dc4) |
|   | Constructs a new [GCKMediaQueueItem](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_media_queue_item "A class representing a media queue item. ") with the given attributes. [More...](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_media_queue_item#ab0f62ba953a7af951e5328ac9b8b5dc4) |
|   ||
| (instancetype) | - [initWithMediaInformation:autoplay:startTime:playbackDuration:preloadTime:activeTrackIDs:customData:](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_media_queue_item#a9c5ea9de7f18e9107f4150680dfa96eb) |
|   | Designated initializer. [More...](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_media_queue_item#a9c5ea9de7f18e9107f4150680dfa96eb) |
|   ||
| (void) | - [clearItemID](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_media_queue_item#a391bbc91fc0c83508a666510a8a22271) |
|   | Clears (unassigns) the item ID. [More...](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_media_queue_item#a391bbc91fc0c83508a666510a8a22271) |
|   ||
| (instancetype) | - [mediaQueueItemModifiedWithBlock:](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_media_queue_item#af0b5a3682d5cb8cebeb4681908ae8ff2) |
|   | Returns a copy of this [GCKMediaQueueItem](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_media_queue_item "A class representing a media queue item. ") that has been modified by the given block. [More...](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_media_queue_item#af0b5a3682d5cb8cebeb4681908ae8ff2) |
|   ||

|---|---|
| ## Property Summary ||
| [GCKMediaInformation](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_media_information) \* | [mediaInformation](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_media_queue_item#a25e392276128eeece36a31f094a44c38) |
|   | The media information associated with this item. [More...](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_media_queue_item#a25e392276128eeece36a31f094a44c38) |
|   ||
| NSUInteger | [itemID](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_media_queue_item#a3896050feb10e4e214e50a567f3a16bd) |
|   | The item ID, or [kGCKMediaQueueInvalidItemID](https://developers.google.com/cast/v3/reference/ios/g_c_k_media_queue_item_8h#a200e0d20acf51d47ce1c90ae982bd4e5) if one has not yet been assigned. [More...](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_media_queue_item#a3896050feb10e4e214e50a567f3a16bd) |
|   ||
| BOOL | [autoplay](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_media_queue_item#a68ee7f0ef862dd27c8f76d8c3dd62e97) |
|   | Whether the item should automatically start playback when it becomes the current item in the queue. [More...](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_media_queue_item#a68ee7f0ef862dd27c8f76d8c3dd62e97) |
|   ||
| NSTimeInterval | [startTime](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_media_queue_item#a73cb96e1e9ad285c2b53065068923a6d) |
|   | The start time of the item, in seconds. [More...](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_media_queue_item#a73cb96e1e9ad285c2b53065068923a6d) |
|   ||
| NSTimeInterval | [playbackDuration](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_media_queue_item#ae71687602d73d1572b1a7c49134c67aa) |
|   | The playback duration for the item, in seconds, or `INFINITY` if the stream's actual duration should be used. [More...](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_media_queue_item#ae71687602d73d1572b1a7c49134c67aa) |
|   ||
| NSTimeInterval | [preloadTime](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_media_queue_item#aae0482ccdbcdf7349d4b90a88a5eb6c2) |
|   | How long before the previous item ends, in seconds, before the receiver should start preloading this item. [More...](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_media_queue_item#aae0482ccdbcdf7349d4b90a88a5eb6c2) |
|   ||
| NSArray\< NSNumber \* \> \* | [activeTrackIDs](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_media_queue_item#a5095257376e3299ef4a4c14252883fc4) |
|   | The active track IDs for this item. [More...](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_media_queue_item#a5095257376e3299ef4a4c14252883fc4) |
|   ||
| id | [customData](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_media_queue_item#aa9419593c194100e41f38dc26f804f63) |
|   | The custom data associated with this item, if any. [More...](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_media_queue_item#aa9419593c194100e41f38dc26f804f63) |
|   ||

## Method Detail

|---|---|---|---|
| - (instancetype) initWithMediaInformation: |   | ([GCKMediaInformation](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_media_information) \*) | *mediaInformation* |
| autoplay: |   | (BOOL) | *autoplay* |
| startTime: |   | (NSTimeInterval) | *startTime* |
| preloadTime: |   | (NSTimeInterval) | *preloadTime* |
| activeTrackIDs: |   | (NSArray\< NSNumber \* \> \*__nullable) | *activeTrackIDs* |
| customData: |   | (id __nullable) | *customData* |
|   |   |   |   |

Constructs a new [GCKMediaQueueItem](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_media_queue_item "A class representing a media queue item. ") with the given attributes.

See the documentation of the corresponding properties for more information.

Parameters
:

    |---|---|
    | mediaInformation | The media information for the item. |
    | autoplay | The autoplay state for this item. |
    | startTime | The start time of the item, in seconds. May be [kGCKInvalidTimeInterval](https://developers.google.com/cast/v3/reference/ios/g_c_k_media_common_8h#abe8984fca7b61be2470630190b919c3b) if this item refers to a live stream or if the default start time should be used. |
    | preloadTime | The preload time for the item, in seconds. May be [kGCKInvalidTimeInterval](https://developers.google.com/cast/v3/reference/ios/g_c_k_media_common_8h#abe8984fca7b61be2470630190b919c3b) to indicate no preload time. |
    | activeTrackIDs | The active track IDs for the item. May be `nil`. |
    | customData | Any custom data to associate with the item. May be `nil`. |


|---|---|---|---|
| - (instancetype) initWithMediaInformation: |   | ([GCKMediaInformation](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_media_information) \*) | *mediaInformation* |
| autoplay: |   | (BOOL) | *autoplay* |
| startTime: |   | (NSTimeInterval) | *startTime* |
| playbackDuration: |   | (NSTimeInterval) | *playbackDuration* |
| preloadTime: |   | (NSTimeInterval) | *preloadTime* |
| activeTrackIDs: |   | (NSArray\< NSNumber \* \> \*__nullable) | *activeTrackIDs* |
| customData: |   | (id __nullable) | *customData* |
|   |   |   |   |

Designated initializer.

Constructs a new [GCKMediaQueueItem](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_media_queue_item "A class representing a media queue item. ") with the given attributes. See the documentation of the corresponding properties for more information.

Parameters
:

    |---|---|
    | mediaInformation | The media information for the item. |
    | autoplay | The autoplay state for this item. |
    | startTime | The start time of the item, in seconds. May be [kGCKInvalidTimeInterval](https://developers.google.com/cast/v3/reference/ios/g_c_k_media_common_8h#abe8984fca7b61be2470630190b919c3b) if this item refers to a live stream or if the default start time should be used. |
    | playbackDuration | The playback duration of the item, in seconds. May be [kGCKInvalidTimeInterval](https://developers.google.com/cast/v3/reference/ios/g_c_k_media_common_8h#abe8984fca7b61be2470630190b919c3b) to indicate no preload time. |
    | preloadTime | The preload time for the item, in seconds. |
    | activeTrackIDs | The active track IDs for the item. May be `nil`. |
    | customData | Any custom data to associate with the item. May be `nil`. |


|---|---|---|---|
| - (void) clearItemID |   |   |   |

Clears (unassigns) the item ID.

Should be called in order to reuse an existing instance, for example, to add it back to a queue.

|---|---|---|---|---|
| - (instancetype) mediaQueueItemModifiedWithBlock: |   | (void(\^)([GCKMediaQueueItemBuilder](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_media_queue_item_builder) \*builder)) | *block* |   |

Returns a copy of this [GCKMediaQueueItem](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_media_queue_item "A class representing a media queue item. ") that has been modified by the given block.

Parameters
:

    |---|---|
    | block | A block that receives a [GCKMediaQueueItemBuilder](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_media_queue_item_builder "A builder object for constructing new or derived GCKMediaQueueItem instances. ") which can be used to modify attributes of the copy. It is not necessary to call the builder's [build (GCKMediaQueueItemBuilder)](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_media_queue_item_builder#a00f0d6bf945b7d13abcc93c31919d8bb "Builds a GCKMediaQueueItem using the builder's current attributes. ") method within the block, as this method will do that automatically when the block completes. |


Returns
:   A modified copy of this item.

## Property Detail

|---|---|
| |---| | - ([GCKMediaInformation](https://developers.google.com/cast/v3/reference/ios/interface_g_c_k_media_information)\*) mediaInformation | | readnonatomicstrong |

The media information associated with this item.

|---|---|
| |---| | - (NSUInteger) itemID | | readnonatomicassign |

The item ID, or [kGCKMediaQueueInvalidItemID](https://developers.google.com/cast/v3/reference/ios/g_c_k_media_queue_item_8h#a200e0d20acf51d47ce1c90ae982bd4e5) if one has not yet been assigned.

|---|---|
| |---| | - (BOOL) autoplay | | readnonatomicassign |

Whether the item should automatically start playback when it becomes the current item in the queue.

If `NO`, the queue will pause when it reaches this item. The default value is `YES`.

|---|---|
| |---| | - (NSTimeInterval) startTime | | readnonatomicassign |

The start time of the item, in seconds.

The default value is [kGCKInvalidTimeInterval](https://developers.google.com/cast/v3/reference/ios/g_c_k_media_common_8h#abe8984fca7b61be2470630190b919c3b), indicating that no start time has been set.

|---|---|
| |---| | - (NSTimeInterval) playbackDuration | | readnonatomicassign |

The playback duration for the item, in seconds, or `INFINITY` if the stream's actual duration should be used.

|---|---|
| |---| | - (NSTimeInterval) preloadTime | | readnonatomicassign |

How long before the previous item ends, in seconds, before the receiver should start preloading this item.

The default value is [kGCKInvalidTimeInterval](https://developers.google.com/cast/v3/reference/ios/g_c_k_media_common_8h#abe8984fca7b61be2470630190b919c3b), indicating that no preload time has been set.

|---|---|
| |---| | - (NSArray\<NSNumber \*\>\*) activeTrackIDs | | readnonatomicstrong |

The active track IDs for this item.

|---|---|
| |---| | - (id) customData | | readnonatomicstrong |

The custom data associated with this item, if any.