GCKRemoteMediaClient Class

GCKRemoteMediaClient Class Reference

Overview

A class for controlling media playback on a Cast receiver.

This class provides the same functionality as the deprecated GCKMediaControlChannel , which it wraps, but with a more convenient API. The main differences are:

  • Each request is represented by a GCKRequest object which can be tracked with a dedicated delegate.
  • The GCKRemoteMediaClient supports multiple listeners rather than a single delegate.
Since
3.0

Inherits NSObject.

Instance Method Summary

(void) 
Adds a listener to this object's list of listeners. More...
(void) 
Removes a listener from this object's list of listeners. More...
Loads and starts playback of a new media item. More...
Loads and optionally starts playback of a new media item. More...
Loads and optionally starts playback of a new media item. More...
Loads and optionally starts playback of a new media item. More...
Loads and optionally starts playback of a new media item. More...
Loads and optionally starts playback of a new media item. More...
Sets the active tracks. More...
Sets the text track style. More...
( GCKRequest *) 
Pauses playback of the current media item. More...
Pauses playback of the current media item. More...
( GCKRequest *) 
- stop
Stops playback of the current media item. More...
Stops playback of the current media item. More...
( GCKRequest *) 
- play
Begins (or resumes) playback of the current media item. More...
Begins (or resumes) playback of the current media item. More...
Seeks to a new position within the current media item. More...
Seeks to a new position within the current media item. More...
Seeks to a new position within the current media item. More...
Loads and optionally starts playback of a new queue of media items. More...
Loads and optionally starts playback of a new queue of media items. More...
Loads and optionally starts playback of a new queue of media items. More...
Inserts a list of new media items into the queue. More...
Inserts a list of new media items into the queue. More...
A convenience method that inserts a single item into the queue. More...
A convenience method that inserts a single item into the queue and makes it the current item. More...
A convenience method that inserts a single item into the queue and makes it the current item. More...
Updates the queue. More...
Updates the queue. More...
Removes a list of media items from the queue. More...
Removes a list of media items from the queue. More...
A convenience method that removes a single item from the queue. More...
Reorders a list of media items in the queue. More...
Reorder a list of media items in the queue. More...
A convenience method that moves a single item in the queue. More...
Jumps to the item with the specified ID in the queue. More...
Jumps to the item with the specified ID in the queue. More...
Jumps to the item with the specified ID in the queue. More...
Moves to the next item in the queue. More...
Moves to the previous item in the queue. More...
Sets the queue repeat mode. More...
Sets the stream volume. More...
Sets the stream volume. More...
Sets whether the stream is muted. More...
Sets whether the stream is muted. More...
Requests updated media status information from the receiver. More...
(NSTimeInterval) 
Returns the approximate stream position as calculated from the last received stream information and the elapsed wall-time since that update. More...
To be called by subclasses whenever a media session begins, namely, right after new media has been successfully loaded on the remote player. More...
To be called by subclasses any time that the mediaStatus object of the client changes. More...
To be called by subclasses any time that the media queue managed by the client changes. More...
To be called by subclasses whenever the GCKMediaStatus::preloadedItemID for the client's mediaStatus changes. More...
To be called by subclasses any time that the metadata changes. More...

Property Summary

BOOL 
A flag that indicates whether this object is connected to a session. More...
The current media status, as reported by the media control channel. More...
The amount of time that has passed since the last media status update was received. More...
A delegate capable of extracting ad break information from the custom data in a GCKMediaStatus object. More...

Method Detail

- (void) addListener: (id< GCKRemoteMediaClientListener >)  listener

Adds a listener to this object's list of listeners.

Parameters
listener
The listener to add.
- (void) removeListener: (id< GCKRemoteMediaClientListener >)  listener

Removes a listener from this object's list of listeners.

Parameters
listener
The listener to remove.
- ( GCKRequest *) loadMedia: ( GCKMediaInformation *)  mediaInfo

Loads and starts playback of a new media item.

Parameters
mediaInfo
An object describing the media item to load.
Returns
The GCKRequest object for tracking this request.
- ( GCKRequest *) loadMedia: ( GCKMediaInformation *)  mediaInfo
autoplay: (BOOL)  autoplay

Loads and optionally starts playback of a new media item.

Parameters
mediaInfo An object describing the media item to load.
autoplay Whether playback should start immediately.
Returns
The GCKRequest object for tracking this request.
- ( GCKRequest *) loadMedia: ( GCKMediaInformation *)  mediaInfo
autoplay: (BOOL)  autoplay
playPosition: (NSTimeInterval)  playPosition

Loads and optionally starts playback of a new media item.

Parameters
mediaInfo An object describing the media item to load.
autoplay Whether playback should start immediately.
playPosition The initial playback position.
Returns
The GCKRequest object for tracking this request.
- ( GCKRequest *) loadMedia: ( GCKMediaInformation *)  mediaInfo
autoplay: (BOOL)  autoplay
playPosition: (NSTimeInterval)  playPosition
customData: (id __nullable)  customData

Loads and optionally starts playback of a new media item.

Parameters
mediaInfo An object describing the media item to load.
autoplay Whether playback should start immediately.
playPosition The initial playback position.
customData Custom application-specific data to pass along with the request. Must either be an object that can be serialized to JSON using NSJSONSerialization , or nil .
Returns
The GCKRequest object for tracking this request.
- ( GCKRequest *) loadMedia: ( GCKMediaInformation *)  mediaInfo
autoplay: (BOOL)  autoplay
playPosition: (NSTimeInterval)  playPosition
activeTrackIDs: (NSArray< NSNumber * > *__nullable)  activeTrackIDs

Loads and optionally starts playback of a new media item.

Parameters
mediaInfo An object describing the media item to load.
autoplay Whether playback should start immediately.
playPosition The initial playback position.
activeTrackIDs An array of integers specifying the active tracks. May be nil .
Returns
The GCKRequest object for tracking this request.
- ( GCKRequest *) loadMedia: ( GCKMediaInformation *)  mediaInfo
autoplay: (BOOL)  autoplay
playPosition: (NSTimeInterval)  playPosition
activeTrackIDs: (NSArray< NSNumber * > *__nullable)  activeTrackIDs
customData: (id __nullable)  customData

Loads and optionally starts playback of a new media item.

Parameters
mediaInfo An object describing the media item to load.
autoplay Whether playback should start immediately.
playPosition The initial playback position.
activeTrackIDs An array of integers specifying the active tracks. May be nil .
customData Custom application-specific data to pass along with the request. Must either be an object that can be serialized to JSON using NSJSONSerialization , or nil .
Returns
The GCKRequest object for tracking this request.
- ( GCKRequest *) setActiveTrackIDs: (NSArray< NSNumber * > *__nullable)  activeTrackIDs

Sets the active tracks.

The request will fail if there is no current media status.

Parameters
activeTrackIDs
An array of integers specifying the active tracks. May be empty or nil to disable any currently active tracks.
Returns
The GCKRequest object for tracking this request.
- ( GCKRequest *) setTextTrackStyle: ( GCKMediaTextTrackStyle *__nullable)  textTrackStyle

Sets the text track style.

The request will fail if there is no current media status.

Parameters
textTrackStyle
The text track style. The style will not be changed if this is nil .
Returns
The GCKRequest object for tracking this request.
- ( GCKRequest *) pause

Pauses playback of the current media item.

The request will fail if there is no current media status.

Returns
The GCKRequest object for tracking this request.
- ( GCKRequest *) pauseWithCustomData: (id __nullable)  customData

Pauses playback of the current media item.

The request will fail if there is no current media status.

Parameters
customData
Custom application-specific data to pass along with the request. Must either be an object that can be serialized to JSON using NSJSONSerialization , or nil .
Returns
The GCKRequest object for tracking this request.
- ( GCKRequest *) stop

Stops playback of the current media item.

If a queue is currently loaded, it will be removed. The request will fail if there is no current media status.

Returns
The GCKRequest object for tracking this request.
- ( GCKRequest *) stopWithCustomData: (id __nullable)  customData

Stops playback of the current media item.

If a queue is currently loaded, it will be removed. The request will fail if there is no current media status.

Parameters
customData
Custom application-specific data to pass along with the request. Must either be an object that can be serialized to JSON using NSJSONSerialization , or nil .
Returns
The GCKRequest object for tracking this request.
- ( GCKRequest *) play

Begins (or resumes) playback of the current media item.

Playback always begins at the beginning of the stream. The request will fail if there is no current media status.

Returns
The GCKRequest object for tracking this request.
- ( GCKRequest *) playWithCustomData: (id __nullable)  customData

Begins (or resumes) playback of the current media item.

Playback always begins at the beginning of the stream. The request will fail if there is no current media status.

Parameters
customData
Custom application-specific data to pass along with the request. Must either be an object that can be serialized to JSON using NSJSONSerialization , or nil .
Returns
The GCKRequest object for tracking this request.
- ( GCKRequest *) seekToTimeInterval: (NSTimeInterval)  position

Seeks to a new position within the current media item.

The request will fail if there is no current media status.

Parameters
position
The new position from the beginning of the stream.
Returns
The GCKRequest object for tracking this request.
- ( GCKRequest *) seekToTimeInterval: (NSTimeInterval)  position
resumeState: ( GCKMediaResumeState resumeState

Seeks to a new position within the current media item.

The request will fail if there is no current media status.

Parameters
position The new position interval from the beginning of the stream.
resumeState The action to take after the seek operation has finished.
Returns
The GCKRequest object for tracking this request.
- ( GCKRequest *) seekToTimeInterval: (NSTimeInterval)  position
resumeState: ( GCKMediaResumeState resumeState
customData: (id __nullable)  customData

Seeks to a new position within the current media item.

The request will fail if there is no current media status.

Parameters
position The new position from the beginning of the stream.
resumeState The action to take after the seek operation has finished.
customData Custom application-specific data to pass along with the request. Must either be an object that can be serialized to JSON using NSJSONSerialization , or nil .
Returns
The GCKRequest object for tracking this request.
- ( GCKRequest *) queueLoadItems: (NSArray< GCKMediaQueueItem * > *)  queueItems
startIndex: (NSUInteger)  startIndex
repeatMode: ( GCKMediaRepeatMode repeatMode

Loads and optionally starts playback of a new queue of media items.

Parameters
queueItems An array of GCKMediaQueueItem instances to load. Must not be nil or empty.
startIndex The index of the item in the items array that should be played first.
repeatMode The repeat mode for playing the queue.
Returns
The GCKRequest object for tracking this request.
- ( GCKRequest *) queueLoadItems: (NSArray< GCKMediaQueueItem * > *)  queueItems
startIndex: (NSUInteger)  startIndex
repeatMode: ( GCKMediaRepeatMode repeatMode
customData: (id __nullable)  customData

Loads and optionally starts playback of a new queue of media items.

Parameters
queueItems An array of GCKMediaQueueItem instances to load. Must not be nil or empty.
startIndex The index of the item in the items array that should be played first.
repeatMode The repeat mode for playing the queue.
customData Custom application-specific data to pass along with the request. Must either be an object that can be serialized to JSON using NSJSONSerialization , or nil .
Returns
The GCKRequest object for tracking this request.
- ( GCKRequest *) queueLoadItems: (NSArray< GCKMediaQueueItem * > *)  queueItems
startIndex: (NSUInteger)  startIndex
playPosition: (NSTimeInterval)  playPosition
repeatMode: ( GCKMediaRepeatMode repeatMode
customData: (id __nullable)  customData

Loads and optionally starts playback of a new queue of media items.

Parameters
queueItems An array of GCKMediaQueueItem instances to load. Must not be nil or empty.
startIndex The index of the item in the items array that should be played first.
playPosition The initial playback position for the item when it is first played, relative to the beginning of the stream. This value is ignored when the same item is played again, for example when the queue repeats, or the item is later jumped to. In those cases the item's startTime is used.
repeatMode The repeat mode for playing the queue.
customData Custom application-specific data to pass along with the request. Must either be an object that can be serialized to JSON using NSJSONSerialization , or nil .
Returns
The GCKRequest object for tracking this request.
- ( GCKRequest *) queueInsertItems: (NSArray< GCKMediaQueueItem * > *)  queueItems
beforeItemWithID: (NSUInteger)  beforeItemID

Inserts a list of new media items into the queue.

Parameters
queueItems An array of GCKMediaQueueItem instances to insert. Must not be nil or empty.
beforeItemID The ID of the item that will be located immediately after the inserted list. If the value is kGCKMediaQueueInvalidItemID , the inserted list will be appended to the end of the queue.
Returns
The GCKRequest object for tracking this request.
- ( GCKRequest *) queueInsertItems: (NSArray< GCKMediaQueueItem * > *)  queueItems
beforeItemWithID: (NSUInteger)  beforeItemID
customData: (id __nullable)  customData

Inserts a list of new media items into the queue.

Parameters
queueItems An array of GCKMediaQueueItem instances to insert. Must not be nil or empty.
beforeItemID ID of the item that will be located immediately after the inserted list. If the value is kGCKMediaQueueInvalidItemID , the inserted list will be appended to the end of the queue.
customData Custom application-specific data to pass along with the request. Must either be an object that can be serialized to JSON using NSJSONSerialization , or nil .
Returns
The GCKRequest object for tracking this request.
- ( GCKRequest *) queueInsertItem: ( GCKMediaQueueItem *)  item
beforeItemWithID: (NSUInteger)  beforeItemID

A convenience method that inserts a single item into the queue.

Parameters
item The item to insert.
beforeItemID The ID of the item that will be located immediately after the inserted item. If the value is kGCKMediaQueueInvalidItemID , or does not refer to any item currently in the queue, the inserted item will be appended to the end of the queue.
Returns
The GCKRequest object for tracking this request.
- ( GCKRequest *) queueInsertAndPlayItem: ( GCKMediaQueueItem *)  item
beforeItemWithID: (NSUInteger)  beforeItemID

A convenience method that inserts a single item into the queue and makes it the current item.

Parameters
item The item to insert.
beforeItemID The ID of the item that will be located immediately after the inserted item. If the value is kGCKMediaQueueInvalidItemID , or does not refer to any item currently in the queue, the inserted item will be appended to the end of the queue.
Returns
The GCKRequest object for tracking this request.
- ( GCKRequest *) queueInsertAndPlayItem: ( GCKMediaQueueItem *)  item
beforeItemWithID: (NSUInteger)  beforeItemID
playPosition: (NSTimeInterval)  playPosition
customData: (id __nullable)  customData

A convenience method that inserts a single item into the queue and makes it the current item.

Parameters
item The item to insert.
beforeItemID The ID of the item that will be located immediately after the inserted item. If the value is kGCKMediaQueueInvalidItemID , or does not refer to any item currently in the queue, the inserted item will be appended to the end of the queue.
playPosition The initial playback position for the item when it is first played, relative to the beginning of the stream. This value is ignored when the same item is played again, for example when the queue repeats, or the item is later jumped to. In those cases the item's startTime is used.
customData Custom application-specific data to pass along with the request. Must either be an object that can be serialized to JSON using NSJSONSerialization , or nil .
Returns
The GCKRequest object for tracking this request.
- ( GCKRequest *) queueUpdateItems: (NSArray< GCKMediaQueueItem * > *)  queueItems

Updates the queue.

Parameters
queueItems
The list of updated items.
Returns
The GCKRequest object for tracking this request.
- ( GCKRequest *) queueUpdateItems: (NSArray< GCKMediaQueueItem * > *)  queueItems
customData: (id __nullable)  customData

Updates the queue.

Parameters
queueItems The list of updated items.
customData Custom application-specific data to pass along with the request. Must either be an object that can be serialized to JSON using NSJSONSerialization , or nil .
Returns
The GCKRequest object for tracking this request.
- ( GCKRequest *) queueRemoveItemsWithIDs: (NSArray< NSNumber * > *)  itemIDs

Removes a list of media items from the queue.

If the queue becomes empty as a result, the current media session will be terminated.

Parameters
itemIDs
An array of media item IDs identifying the items to remove. Must not be nil or empty.
Returns
The GCKRequest object for tracking this request.
- ( GCKRequest *) queueRemoveItemsWithIDs: (NSArray< NSNumber * > *)  itemIDs
customData: (id __nullable)  customData

Removes a list of media items from the queue.

If the queue becomes empty as a result, the current media session will be terminated.

Parameters
itemIDs An array of media item IDs identifying the items to remove. Must not be nil or empty.
customData Custom application-specific data to pass along with the request. Must either be an object that can be serialized to JSON using NSJSONSerialization , or nil .
Returns
The GCKRequest object for tracking this request.
- ( GCKRequest *) queueRemoveItemWithID: (NSUInteger)  itemID

A convenience method that removes a single item from the queue.

Parameters
itemID
The ID of the item to remove.
Returns
The GCKRequest object for tracking this request.
- ( GCKRequest *) queueReorderItemsWithIDs: (NSArray< NSNumber * > *)  queueItemIDs
insertBeforeItemWithID: (NSUInteger)  beforeItemID

Reorders a list of media items in the queue.

Parameters
queueItemIDs An array of media item IDs identifying the items to reorder. Must not be nil or empty.
beforeItemID ID of the item that will be located immediately after the reordered list. If the value is kGCKMediaQueueInvalidItemID , or does not refer to any item currently in the queue, the reordered list will be appended at the end of the queue.
Returns
The GCKRequest object for tracking this request.
- ( GCKRequest *) queueReorderItemsWithIDs: (NSArray< NSNumber * > *)  queueItemIDs
insertBeforeItemWithID: (NSUInteger)  beforeItemID
customData: (id __nullable)  customData

Reorder a list of media items in the queue.

Parameters
queueItemIDs An array of media item IDs identifying the items to reorder. Must not be nil or empty.
beforeItemID The ID of the item that will be located immediately after the reordered list. If the value is kGCKMediaQueueInvalidItemID , or does not refer to any item currently in the queue, the reordered list will be moved to the end of the queue.
customData Custom application-specific data to pass along with the request. Must either be an object that can be serialized to JSON using NSJSONSerialization , or nil .
Returns
The GCKRequest object for tracking this request.
- ( GCKRequest *) queueMoveItemWithID: (NSUInteger)  itemID
beforeItemWithID: (NSUInteger)  beforeItemID

A convenience method that moves a single item in the queue.

Parameters
itemID The ID of the item to move.
beforeItemID The ID of the item that will be located immediately after the reordered list. If the value is kGCKMediaQueueInvalidItemID , or does not refer to any item currently in the queue, the item will be moved to the end of the queue.
Returns
The GCKRequest object for tracking this request.
- ( GCKRequest *) queueJumpToItemWithID: (NSUInteger)  itemID

Jumps to the item with the specified ID in the queue.

Parameters
itemID
The ID of the item to jump to.
Returns
The GCKRequest object for tracking this request.
- ( GCKRequest *) queueJumpToItemWithID: (NSUInteger)  itemID
customData: (id __nullable)  customData

Jumps to the item with the specified ID in the queue.

Parameters
itemID The ID of the item to jump to.
customData Custom application-specific data to pass along with the request. Must either be an object that can be serialized to JSON using NSJSONSerialization , or nil .
Returns
The GCKRequest object for tracking this request.
- ( GCKRequest *) queueJumpToItemWithID: (NSUInteger)  itemID
playPosition: (NSTimeInterval)  playPosition
customData: (id __nullable)  customData

Jumps to the item with the specified ID in the queue.

Parameters
itemID The ID of the item to jump to.
playPosition The initial playback position for the item when it is first played, relative to the beginning of the stream. This value is ignored when the same item is played again, for example when the queue repeats, or the item is later jumped to. In those cases the item's startTime is used.
customData Custom application-specific data to pass along with the request. Must either be an object that can be serialized to JSON using NSJSONSerialization , or nil .
Returns
The GCKRequest object for tracking this request.
- ( GCKRequest *) queueNextItem

Moves to the next item in the queue.

Returns
The GCKRequest object for tracking this request.
- ( GCKRequest *) queuePreviousItem

Moves to the previous item in the queue.

Returns
The GCKRequest object for tracking this request.
- ( GCKRequest *) queueSetRepeatMode: ( GCKMediaRepeatMode repeatMode

Sets the queue repeat mode.

Parameters
repeatMode
The new repeat mode.
Returns
The GCKRequest object for tracking this request.
- ( GCKRequest *) setStreamVolume: (float)  volume

Sets the stream volume.

The request will fail if there is no current media session.

Parameters
volume
The new volume, in the range [0.0 - 1.0].
Returns
The GCKRequest object for tracking this request.
- ( GCKRequest *) setStreamVolume: (float)  volume
customData: (id __nullable)  customData

Sets the stream volume.

The request will fail if there is no current media session.

Parameters
volume The new volume, in the range [0.0 - 1.0].
customData Custom application-specific data to pass along with the request. Must either be an object that can be serialized to JSON using NSJSONSerialization , or nil .
Returns
The GCKRequest object for tracking this request.
- ( GCKRequest *) setStreamMuted: (BOOL)  muted

Sets whether the stream is muted.

The request will fail if there is no current media session.

Parameters
muted
Whether the stream should be muted or unmuted.
Returns
The GCKRequest object for tracking this request.
- ( GCKRequest *) setStreamMuted: (BOOL)  muted
customData: (id __nullable)  customData

Sets whether the stream is muted.

The request will fail if there is no current media session.

Parameters
muted Whether the stream should be muted or unmuted.
customData Custom application-specific data to pass along with the request. Must either be an object that can be serialized to JSON using NSJSONSerialization , or nil .
Returns
The GCKRequest object for tracking this request.
- ( GCKRequest *) requestStatus

Requests updated media status information from the receiver.

Returns
The GCKRequest object for tracking this request.
- (NSTimeInterval) approximateStreamPosition

Returns the approximate stream position as calculated from the last received stream information and the elapsed wall-time since that update.

Returns 0 if the channel is not connected or if no media is currently loaded.

- (void) notifyDidStartMediaSession

To be called by subclasses whenever a media session begins, namely, right after new media has been successfully loaded on the remote player.

Provided by category GCKRemoteMediaClient(Protected) .

- (void) notifyDidUpdateMediaStatus

To be called by subclasses any time that the mediaStatus object of the client changes.

Provided by category GCKRemoteMediaClient(Protected) .

- (void) notifyDidUpdateQueue

To be called by subclasses any time that the media queue managed by the client changes.

Provided by category GCKRemoteMediaClient(Protected) .

- (void) notifyDidUpdatePreloadStatus

To be called by subclasses whenever the GCKMediaStatus::preloadedItemID for the client's mediaStatus changes.

Provided by category GCKRemoteMediaClient(Protected) .

- (void) notifyDidUpdateMetadata

To be called by subclasses any time that the metadata changes.

Provided by category GCKRemoteMediaClient(Protected) .

Property Detail

- (BOOL) connected
read nonatomic assign

A flag that indicates whether this object is connected to a session.

- ( GCKMediaStatus *) mediaStatus
read nonatomic strong

The current media status, as reported by the media control channel.

- (NSTimeInterval) timeSinceLastMediaStatusUpdate
read nonatomic assign

The amount of time that has passed since the last media status update was received.

If a status request is currently in progress, this will be 0.

- (id< GCKRemoteMediaClientAdInfoParserDelegate >) adInfoParserDelegate
read write nonatomic weak

A delegate capable of extracting ad break information from the custom data in a GCKMediaStatus object.

Deprecated:
Use GCKAdBreakStatus instead.
Create a Mobile Website
View Site in Mobile | Classic
Share by: