總覽
任意長度的媒體佇列的資料模型表示法。
此類別可做為 UITableViewDataSource 實作的基礎,用於驅動媒體佇列 UI。
GCKMediaQueue 會監聽 GCKSessionManager 事件,並在投放工作階段開始時自動附加至 GCKRemoteMediaClient。它會監聽 GCKRemoteMediaClient 的佇列變更通知,並據此更新內部資料模型。同樣地,它會使用 GCKRemoteMediaClient 隨選擷取佇列資訊。
這個模型會維護整個佇列的佇列項目 ID 清單,並在附加至投放工作階段時自動擷取清單。也會維護 GCKMediaQueueItems 的 LRU 快取 (可設定大小),此快取由佇列項目 ID 索引鍵。
itemAtIndex: (GCKMediaQueue) 方法可用來擷取指定索引的佇列項目。如果 GCKMediaQueueItem 目前不在快取中,系統會發出非同步要求,以便從接收器擷取該項目,並且最終會在收到要求的項目時通知委派。
如果在極短時間內多次呼叫這個方法,要求的項目 ID 會在內部批次處理,減少發出的網路要求數量。由於接收端一次可擷取的佇列項目數量上限,因此 GCKMediaQueue 會保留最後 N 個項目 ID 的滾動式視窗。因此在短時間內要求大量項目時,實際上只會擷取最後 N 個項目。這種行為可有效管理應用程式 UI 中非常長的佇列,使用者可迅速且/或經常捲動畫面。
GCKMediaQueue 不會提供任何直接修改佇列的方法,因為這類變更涉及對接收器 (透過 GCKRemoteMediaClient 上的方法) 的非同步網路要求,而這可能會失敗並發生錯誤。GCKMediaQueue 必須確保佇列中的表示法在接收器中一致,因此如果對資料模型進行本機變更,而該模型尚未在接收器上修訂,可能會導致 UI 行為不正確。
如需委派通訊協定,請參閱 GCKMediaQueueDelegate。
- 開始時間
- 4.3.4
繼承 NSObject。
| 執行個體方法摘要 | |
| (instancetype) | - init | 
| (instancetype) | - initWithRemoteMediaClient: | 
| 使用預設快取大小和預設擷取數量上限來初始化新的 GCKMediaQueue。更多... | |
| (instancetype) | - initWithRemoteMediaClient:cacheSize: | 
| 使用指定的快取大小和預設擷取數量上限來初始化新的 GCKMediaQueue。更多... | |
| (instancetype) | - initWithRemoteMediaClient:cacheSize:maxFetchCount: | 
| 使用指定的快取大小和指定的擷取數量上限來初始化新的 GCKMediaQueue。更多... | |
| (void) | - addDelegate: | 
| 將委派作業新增至這個物件的委派清單。更多... | |
| (void) | - removeDelegate: | 
| 從這個物件的委派清單移除委派對象。更多... | |
| (nullable GCKMediaQueueItem *) | - itemAtIndex: | 
| 傳回佇列中特定索引的媒體佇列項目;如果目前不在快取中,則排列從接收器擷取的項目。更多... | |
| (nullable GCKMediaQueueItem *) | - itemAtIndex:fetchIfNeeded: | 
| 傳回佇列中特定索引的媒體佇列項目;如果目前不在快取中,則選擇性地安排從接收器擷取項目。更多... | |
| (GCKMediaQueueItemID) | - itemIDAtIndex: | 
| 傳回佇列中指定索引的項目項目 ID。更多... | |
| (NSInteger) | - indexOfItemWithID: | 
| 查詢佇列中佇列項目的索引。更多... | |
| (void) | - reload | 
| 重新載入佇列。更多... | |
| (void) | - clear | 
| 清除佇列,移除所有元素並清除快取。更多... | |
| 資源摘要 | |
| NSUInteger | itemCount | 
| 佇列中目前的項目數量。更多... | |
| NSUInteger | cacheSize | 
| 快取大小。更多... | |
| NSUInteger | cachedItemCount | 
| 目前在快取中的佇列項目數量。更多... | |
方法詳細資料
| - (instancetype) initWithRemoteMediaClient: | (GCKRemoteMediaClient *) | remoteMediaClient | 
使用預設快取大小和預設擷取數量上限來初始化新的 GCKMediaQueue。
| - (instancetype) initWithRemoteMediaClient: | (GCKRemoteMediaClient *) | remoteMediaClient | |
| cacheSize: | (NSUInteger) | cacheSize | |
使用指定的快取大小和預設擷取數量上限來初始化新的 GCKMediaQueue。
- Parameters
- 
  cacheSize The cache size. Must be nonzero. 
| - (instancetype) initWithRemoteMediaClient: | (GCKRemoteMediaClient *) | remoteMediaClient | |
| cacheSize: | (NSUInteger) | cacheSize | |
| maxFetchCount: | (NSUInteger) | maxFetchCount | |
使用指定的快取大小和指定的擷取數量上限來初始化新的 GCKMediaQueue。
- Parameters
- 
  cacheSize The cache size. Must be nonzero. maxFetchCount The maxiumum fetch count with minimum being 1. 
| - (void) addDelegate: | (id< GCKMediaQueueDelegate >) | delegate | 
將委派作業新增至這個物件的委派清單。
- Parameters
- 
  delegate The delegate to add. The delegate will be retained until removeDelegate: is called. 
| - (void) removeDelegate: | (id< GCKMediaQueueDelegate >) | delegate | 
從這個物件的委派清單移除委派對象。
- Parameters
- 
  delegate The delegate to remove. 
| - (nullable GCKMediaQueueItem *) itemAtIndex: | (NSUInteger) | index | 
傳回佇列中特定索引的媒體佇列項目;如果目前不在快取中,則排列從接收器擷取的項目。
- Parameters
- 
  index The index of the item to fetch. 
- 傳回
- 指定索引中的項目;如果項目目前不在快取中,但將以非同步方式擷取,則該項目為 nil。
| - (nullable GCKMediaQueueItem *) itemAtIndex: | (NSUInteger) | index | |
| fetchIfNeeded: | (BOOL) | fetch | |
傳回佇列中特定索引的媒體佇列項目;如果目前不在快取中,則選擇性地安排從接收器擷取項目。
- Parameters
- 
  index The index of the item to fetch. fetch Whether the item should be fetched from the receiver if it is not currently in the cache. 
- 傳回
- 指定索引的項目;如果項目目前不在快取中,則為 nil。
| - (GCKMediaQueueItemID) itemIDAtIndex: | (NSUInteger) | index | 
傳回佇列中指定索引的項目項目 ID。
- 傳回
- 指定索引的項目 ID;如果索引無效,則為 kGCKMediaQueueInvalidItemID。
| - (NSInteger) indexOfItemWithID: | (GCKMediaQueueItemID) | itemID | 
查詢佇列中佇列項目的索引。
- Parameters
- 
  itemID The queue item ID. 
- 傳回
- 佇列中項目的索引 (也就是基數位置);如果佇列中沒有該項目,則為 NSNotFound。
| - (void) reload | 
重新載入佇列。
系統會清除快取,並從接收者重新擷取項目 ID 清單。
| - (void) clear | 
清除佇列,移除所有元素並清除快取。
資源詳情
| 
 | readnonatomicassign | 
佇列中目前的項目數量。
| 
 | readnonatomicassign | 
快取大小。
| 
 | readnonatomicassign | 
目前在快取中的佇列項目數量。