概览
用于控制 Cast 接收器上的媒体播放的类。
此类提供与已废弃的 GCKMediaControlChannel(已封装)相同的功能,但 API 更便捷。主要区别如下:
- 每个请求都由 GCKRequest 对象表示,该对象可通过专用委托进行跟踪。
- GCKRemoteMediaClient 支持多个监听器,而不是单个委托。
- 辛塞
- 3.0
此类继承 NSObject。
属性摘要 | |
BOOL | connected |
一个标记,指示此对象是否已连接到会话。更多... | |
GCKMediaStatus * | mediaStatus |
媒体控制渠道报告的当前媒体状态。更多... | |
NSTimeInterval | timeSinceLastMediaStatusUpdate |
自上次收到媒体状态更新以来经过的时间。更多... | |
id< GCKRemoteMediaClientAdInfoParserDelegate > | adInfoParserDelegate |
能够从 GCKMediaStatus 对象中的自定义数据中提取广告插播时间点信息的代理。更多... | |
方法详细信息
- (void) addListener: | (id< GCKRemoteMediaClientListener >) | listener |
向此对象的监听器列表中添加监听器。
- Parameters
-
listener The listener to add.
- (void) removeListener: | (id< GCKRemoteMediaClientListener >) | listener |
从此对象的监听器列表中移除监听器。
- Parameters
-
listener The listener to remove.
- (GCKRequest *) loadMedia: | (GCKMediaInformation *) | mediaInfo |
加载并开始播放新媒体项。
- Parameters
-
mediaInfo An object describing the media item to load.
- 返回
- 用于跟踪此请求的 GCKRequest 对象。
- (GCKRequest *) loadMedia: | (GCKMediaInformation *) | mediaInfo | |
autoplay: | (BOOL) | autoplay | |
加载新的媒体项并选择播放。
- Parameters
-
mediaInfo An object describing the media item to load. autoplay Whether playback should start immediately.
- 返回
- 用于跟踪此请求的 GCKRequest 对象。
- (GCKRequest *) loadMedia: | (GCKMediaInformation *) | mediaInfo | |
autoplay: | (BOOL) | autoplay | |
playPosition: | (NSTimeInterval) | playPosition | |
加载新的媒体项并选择播放。
- Parameters
-
mediaInfo An object describing the media item to load. autoplay Whether playback should start immediately. playPosition The initial playback position.
- 返回
- 用于跟踪此请求的 GCKRequest 对象。
- (GCKRequest *) loadMedia: | (GCKMediaInformation *) | mediaInfo | |
autoplay: | (BOOL) | autoplay | |
playPosition: | (NSTimeInterval) | playPosition | |
customData: | (id __nullable) | customData | |
加载新的媒体项并选择播放。
- 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
.
- 返回
- 用于跟踪此请求的 GCKRequest 对象。
- (GCKRequest *) loadMedia: | (GCKMediaInformation *) | mediaInfo | |
autoplay: | (BOOL) | autoplay | |
playPosition: | (NSTimeInterval) | playPosition | |
activeTrackIDs: | (NSArray< NSNumber * > *__nullable) | activeTrackIDs | |
加载新的媒体项并选择播放。
- 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
.
- 返回
- 用于跟踪此请求的 GCKRequest 对象。
- (GCKRequest *) loadMedia: | (GCKMediaInformation *) | mediaInfo | |
autoplay: | (BOOL) | autoplay | |
playPosition: | (NSTimeInterval) | playPosition | |
activeTrackIDs: | (NSArray< NSNumber * > *__nullable) | activeTrackIDs | |
customData: | (id __nullable) | customData | |
加载新的媒体项并选择播放。
- 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
.
- 返回
- 用于跟踪此请求的 GCKRequest 对象。
- (GCKRequest *) setActiveTrackIDs: | (NSArray< NSNumber * > *__nullable) | activeTrackIDs |
设置有效曲目。
如果没有当前媒体状态,请求将失败。
- Parameters
-
activeTrackIDs An array of integers specifying the active tracks. May be empty or nil
to disable any currently active tracks.
- 返回
- 用于跟踪此请求的 GCKRequest 对象。
- (GCKRequest *) setTextTrackStyle: | (GCKMediaTextTrackStyle *__nullable) | textTrackStyle |
设置文本轨道样式。
如果没有当前媒体状态,请求将失败。
- Parameters
-
textTrackStyle The text track style. The style will not be changed if this is nil
.
- 返回
- 用于跟踪此请求的 GCKRequest 对象。
- (GCKRequest *) pause |
- (GCKRequest *) pauseWithCustomData: | (id __nullable) | customData |
暂停播放当前媒体项。
如果没有当前媒体状态,请求将失败。
- 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
.
- 返回
- 用于跟踪此请求的 GCKRequest 对象。
- (GCKRequest *) stop |
- (GCKRequest *) stopWithCustomData: | (id __nullable) | customData |
停止播放当前媒体项。
如果某个队列当前已加载,则该队列将被移除。如果没有当前媒体状态,请求将失败。
- 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
.
- 返回
- 用于跟踪此请求的 GCKRequest 对象。
- (GCKRequest *) play |
- (GCKRequest *) playWithCustomData: | (id __nullable) | customData |
开始(或继续)播放当前媒体项。
播放始终从数据流的开头开始。如果没有当前媒体状态,请求将失败。
- 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
.
- 返回
- 用于跟踪此请求的 GCKRequest 对象。
- (GCKRequest *) seekToTimeInterval: | (NSTimeInterval) | position |
跳转到当前媒体项内的新位置。
如果没有当前媒体状态,请求将失败。
- Parameters
-
position The new position from the beginning of the stream.
- 返回
- 用于跟踪此请求的 GCKRequest 对象。
- (GCKRequest *) seekToTimeInterval: | (NSTimeInterval) | position | |
resumeState: | (GCKMediaResumeState) | resumeState | |
跳转到当前媒体项内的新位置。
如果没有当前媒体状态,请求将失败。
- Parameters
-
position The new position interval from the beginning of the stream. resumeState The action to take after the seek operation has finished.
- 返回
- 用于跟踪此请求的 GCKRequest 对象。
- (GCKRequest *) seekToTimeInterval: | (NSTimeInterval) | position | |
resumeState: | (GCKMediaResumeState) | resumeState | |
customData: | (id __nullable) | customData | |
跳转到当前媒体项内的新位置。
如果没有当前媒体状态,请求将失败。
- 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
.
- 返回
- 用于跟踪此请求的 GCKRequest 对象。
- (GCKRequest *) queueLoadItems: | (NSArray< GCKMediaQueueItem * > *) | queueItems | |
startIndex: | (NSUInteger) | startIndex | |
repeatMode: | (GCKMediaRepeatMode) | repeatMode | |
加载新的媒体项队列,并可根据需要开始播放。
- 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.
- 返回
- 用于跟踪此请求的 GCKRequest 对象。
- (GCKRequest *) queueLoadItems: | (NSArray< GCKMediaQueueItem * > *) | queueItems | |
startIndex: | (NSUInteger) | startIndex | |
repeatMode: | (GCKMediaRepeatMode) | repeatMode | |
customData: | (id __nullable) | customData | |
加载新的媒体项队列,并可根据需要开始播放。
- 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
.
- 返回
- 用于跟踪此请求的 GCKRequest 对象。
- (GCKRequest *) queueLoadItems: | (NSArray< GCKMediaQueueItem * > *) | queueItems | |
startIndex: | (NSUInteger) | startIndex | |
playPosition: | (NSTimeInterval) | playPosition | |
repeatMode: | (GCKMediaRepeatMode) | repeatMode | |
customData: | (id __nullable) | customData | |
加载新的媒体项队列,并可根据需要开始播放。
- 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
.
- 返回
- 用于跟踪此请求的 GCKRequest 对象。
- (GCKRequest *) queueInsertItems: | (NSArray< GCKMediaQueueItem * > *) | queueItems | |
beforeItemWithID: | (NSUInteger) | beforeItemID | |
用于将新媒体项列表插入队列。
- 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.
- 返回
- 用于跟踪此请求的 GCKRequest 对象。
- (GCKRequest *) queueInsertItems: | (NSArray< GCKMediaQueueItem * > *) | queueItems | |
beforeItemWithID: | (NSUInteger) | beforeItemID | |
customData: | (id __nullable) | customData | |
用于将新媒体项列表插入队列。
- 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
.
- 返回
- 用于跟踪此请求的 GCKRequest 对象。
- (GCKRequest *) queueInsertItem: | (GCKMediaQueueItem *) | item | |
beforeItemWithID: | (NSUInteger) | beforeItemID | |
一种将单个项插入队列的便捷方法。
- 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.
- 返回
- 用于跟踪此请求的 GCKRequest 对象。
- (GCKRequest *) queueInsertAndPlayItem: | (GCKMediaQueueItem *) | item | |
beforeItemWithID: | (NSUInteger) | beforeItemID | |
一种将单个项插入队列并使其成为当前项的便捷方法。
- 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.
- 返回
- 用于跟踪此请求的 GCKRequest 对象。
- (GCKRequest *) queueInsertAndPlayItem: | (GCKMediaQueueItem *) | item | |
beforeItemWithID: | (NSUInteger) | beforeItemID | |
playPosition: | (NSTimeInterval) | playPosition | |
customData: | (id __nullable) | customData | |
一种将单个项插入队列并使其成为当前项的便捷方法。
- 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
.
- 返回
- 用于跟踪此请求的 GCKRequest 对象。
- (GCKRequest *) queueUpdateItems: | (NSArray< GCKMediaQueueItem * > *) | queueItems |
- (GCKRequest *) queueUpdateItems: | (NSArray< GCKMediaQueueItem * > *) | queueItems | |
customData: | (id __nullable) | customData | |
更新队列。
- 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
.
- 返回
- 用于跟踪此请求的 GCKRequest 对象。
- (GCKRequest *) queueRemoveItemsWithIDs: | (NSArray< NSNumber * > *) | itemIDs |
从队列中移除媒体项列表。
如果队列因此而清空,则当前的媒体会话将被终止。
- Parameters
-
itemIDs An array of media item IDs identifying the items to remove. Must not be nil
or empty.
- 返回
- 用于跟踪此请求的 GCKRequest 对象。
- (GCKRequest *) queueRemoveItemsWithIDs: | (NSArray< NSNumber * > *) | itemIDs | |
customData: | (id __nullable) | customData | |
从队列中移除媒体项列表。
如果队列因此而清空,则当前的媒体会话将被终止。
- 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
.
- 返回
- 用于跟踪此请求的 GCKRequest 对象。
- (GCKRequest *) queueRemoveItemWithID: | (NSUInteger) | itemID |
- (GCKRequest *) queueReorderItemsWithIDs: | (NSArray< NSNumber * > *) | queueItemIDs | |
insertBeforeItemWithID: | (NSUInteger) | beforeItemID | |
对队列中的媒体项列表进行重新排序。
- 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.
- 返回
- 用于跟踪此请求的 GCKRequest 对象。
- (GCKRequest *) queueReorderItemsWithIDs: | (NSArray< NSNumber * > *) | queueItemIDs | |
insertBeforeItemWithID: | (NSUInteger) | beforeItemID | |
customData: | (id __nullable) | customData | |
对队列中的媒体项列表进行重新排序。
- 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
.
- 返回
- 用于跟踪此请求的 GCKRequest 对象。
- (GCKRequest *) queueMoveItemWithID: | (NSUInteger) | itemID | |
beforeItemWithID: | (NSUInteger) | beforeItemID | |
一种用于移动队列中单项内容的便捷方法。
- 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.
- 返回
- 用于跟踪此请求的 GCKRequest 对象。
- (GCKRequest *) queueJumpToItemWithID: | (NSUInteger) | itemID |
- (GCKRequest *) queueJumpToItemWithID: | (NSUInteger) | itemID | |
customData: | (id __nullable) | customData | |
跳至队列中具有指定 ID 的内容。
- 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
.
- 返回
- 用于跟踪此请求的 GCKRequest 对象。
- (GCKRequest *) queueJumpToItemWithID: | (NSUInteger) | itemID | |
playPosition: | (NSTimeInterval) | playPosition | |
customData: | (id __nullable) | customData | |
跳至队列中具有指定 ID 的内容。
- 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
.
- 返回
- 用于跟踪此请求的 GCKRequest 对象。
- (GCKRequest *) queueNextItem |
移至队列中的下一项。
- 返回
- 用于跟踪此请求的 GCKRequest 对象。
- (GCKRequest *) queuePreviousItem |
移至队列中的上一项。
- 返回
- 用于跟踪此请求的 GCKRequest 对象。
- (GCKRequest *) queueSetRepeatMode: | (GCKMediaRepeatMode) | repeatMode |
- (GCKRequest *) setStreamVolume: | (float) | volume |
设置流音量。
如果没有当前媒体会话,请求将失败。
- Parameters
-
volume The new volume, in the range [0.0 - 1.0].
- 返回
- 用于跟踪此请求的 GCKRequest 对象。
- (GCKRequest *) setStreamVolume: | (float) | volume | |
customData: | (id __nullable) | customData | |
设置流音量。
如果没有当前媒体会话,请求将失败。
- 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
.
- 返回
- 用于跟踪此请求的 GCKRequest 对象。
- (GCKRequest *) setStreamMuted: | (BOOL) | muted |
设置流是否静音。
如果没有当前媒体会话,请求将失败。
- Parameters
-
muted Whether the stream should be muted or unmuted.
- 返回
- 用于跟踪此请求的 GCKRequest 对象。
- (GCKRequest *) setStreamMuted: | (BOOL) | muted | |
customData: | (id __nullable) | customData | |
设置流是否静音。
如果没有当前媒体会话,请求将失败。
- 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
.
- 返回
- 用于跟踪此请求的 GCKRequest 对象。
- (GCKRequest *) requestStatus |
从接收器请求更新后的媒体状态信息。
- 返回
- 用于跟踪此请求的 GCKRequest 对象。
- (NSTimeInterval) approximateStreamPosition |
返回上次更新的信息流位置,根据上次接收的信息流信息和自更新以来所用时间。
如果频道未连接或当前未加载任何媒体,则返回 0。
- (void) notifyDidStartMediaSession |
每当媒体会话启动时,即在远程播放器上成功加载新媒体后立即由子类调用。
由类别“GCKRemoteMediaClient(Protected)”提供。
- (void) notifyDidUpdateMediaStatus |
每当客户端的 mediaStatus 对象发生更改时,都由子类调用。
由类别“GCKRemoteMediaClient(Protected)”提供。
- (void) notifyDidUpdateQueue |
每当客户端管理的媒体队列发生更改时,子类都要调用该回调函数。
由类别“GCKRemoteMediaClient(Protected)”提供。
- (void) notifyDidUpdatePreloadStatus |
每当客户端的 mediaStatus 的 GCKMediaStatus::preloadedItemID 发生变化时,由子类调用。
由类别“GCKRemoteMediaClient(Protected)”提供。
- (void) notifyDidUpdateMetadata |
在元数据发生变化时由子类调用。
由类别“GCKRemoteMediaClient(Protected)”提供。
属性详情
|
readnonatomicassign |
一个标记,指示此对象是否已连接到会话。
|
readnonatomicstrong |
媒体控制渠道报告的当前媒体状态。
|
readnonatomicassign |
自上次收到媒体状态更新以来经过的时间。
如果状态请求当前正在执行,此值将为 0。
|
readwritenonatomicweak |
能够从 GCKMediaStatus 对象中的自定义数据中提取广告插播时间点信息的代理。