更新廣播。舉例來說,您可以修改 liveBroadcast
資源的 contentDetails
物件中定義的廣播設定。
常見用途
要求
HTTP 要求
PUT https://www.googleapis.com/youtube/v3/liveBroadcasts
授權
這項要求至少需要取得下列其中一個範圍的授權 (進一步瞭解驗證和授權)。
範圍 |
---|
https://www.googleapis.com/auth/youtube |
https://www.googleapis.com/auth/youtube.force-ssl |
參數
下表列出這項查詢支援的參數。這裡列出的所有參數都是查詢參數。
參數 | ||
---|---|---|
必要參數 | ||
part |
string part 參數在這項操作中有兩個目的。這個 ID 會指出寫入作業將設定的屬性,以及 API 回應要包含的屬性。您可以在參數值中加入 id 、snippet 、contentDetails 、monetizationDetails 和 status 。請注意,這個方法會覆寫參數值指定之所有可變動屬性的現有值。 part 舉例來說,廣播的隱私權狀態定義請見 status 部分。因此,如果您的要求要更新私人或不公開的廣播,且要求的 part 參數值包含 status 部分,則廣播的隱私權設定會更新為要求主體指定的值。如果要求主體未指定值,系統將移除現有的隱私權設定,並將直播還原為預設的隱私設定。 |
|
選用參數 | ||
onBehalfOfContentOwner |
string 這個參數只能用於適當的授權請求。注意:這個參數僅供 YouTube 內容合作夥伴使用。 onBehalfOfContentOwner 參數代表請求的授權憑證可用來識別 YouTube CMS 使用者,其身分為參數值中指定的內容擁有者。這個參數專供擁有和管理許多不同 YouTube 頻道的 YouTube 內容合作夥伴使用。有了這個平台,內容擁有者只要進行一次驗證程序,就能存取所有影片和頻道資料,而不需針對各個頻道提供驗證憑證。使用者進行驗證時使用的 CMS 帳戶必須連結至指定的 YouTube 內容擁有者。 |
|
onBehalfOfContentOwnerChannel |
string 這個參數只能用於適當的授權請求。這個參數只能用於適當的授權請求。注意:這個參數僅供 YouTube 內容合作夥伴使用。 「 onBehalfOfContentOwnerChannel 」參數可指定影片的 YouTube 頻道 ID。因為要求指定 onBehalfOfContentOwner 參數值時,這是必要參數,而且只能搭配該參數使用。此外,用來授權請求的 CMS 帳戶必須與 onBehalfOfContentOwner 參數指定的內容擁有者連結。最後,onBehalfOfContentOwnerChannel 參數值指定的頻道必須連結至 onBehalfOfContentOwner 參數指定的內容擁有者。這個參數適用於擁有和管理許多不同 YouTube 頻道的 YouTube 內容合作夥伴。透過這項機制,內容擁有者即可驗證一次參數值,並代表參數值中代表頻道執行動作,而不必為每個個別頻道提供驗證憑證。 |
要求主體
在要求主體中提供 liveBroadcast 資源。針對該資源:
-
您必須為以下屬性指定值:
id
snippet.scheduledStartTime
contentDetails.monitorStream.enableMonitorStream
contentDetails.monitorStream.broadcastStreamDelayMs
-
您可以為以下屬性設定值:
snippet.title
snippet.description
snippet.scheduledStartTime
snippet.scheduledEndTime
status.privacyStatus
contentDetails.monitorStream.enableMonitorStream
contentDetails.monitorStream.broadcastStreamDelayMs
contentDetails.enableAutoStart
contentDetails.enableAutoStop
contentDetails.enableClosedCaptions
contentDetails.enableDvr
contentDetails.enableEmbed
contentDetails.recordFromStart
monetizationDetails.cuepointSchedule.pauseAdsUntil
如果您提交更新要求,而您的要求並未針對已有值的屬性值指定值,則該屬性的現有值將會刪除。
回應
如果成功的話,這個方法會在回應主體中傳回 liveBroadcast 資源。
錯誤
下表列出 API 可在呼叫此方法時傳回的錯誤訊息。詳情請參閱錯誤訊息說明文件。
錯誤類型 | 錯誤詳細資料 | 說明 |
---|---|---|
forbidden (403) |
closedCaptionsTypeModificationNotAllowed |
只有在廣播處於 created 或 ready 狀態時,才能修改 contentDetails.closedCaptionsType 值。 |
forbidden (403) |
enabledModificationNotAllowed |
enabled 欄位為唯讀欄位。 |
forbidden (403) |
scheduleStrategyModificationNotAllowed |
scheduleStrategy 欄位為唯讀欄位。 |
forbidden (403) |
repeatIntervalSecsModificationNotAllowed |
repeatIntervalSecs 欄位為唯讀欄位。 |
forbidden (403) |
pauseAdsUntilModificationNotAllowed |
無法修改 pauseAdsUntil 欄位。這個錯誤可能的原因如下:
|
forbidden (403) |
enableAutoStartModificationNotAllowed |
只有在串流未啟用且播送處於 created 或 ready 狀態時,才能修改 contentDetails.enableAutoStart 值。 |
forbidden (403) |
enableClosedCaptionsModificationNotAllowed |
只有在廣播處於 created 或 ready 狀態時,才能修改 contentDetails.enableClosedCaptions 值。 |
forbidden (403) |
enableDvrModificationNotAllowed |
只有在廣播處於 created 或 ready 狀態時,才能修改 contentDetails. 值。 |
forbidden (403) |
enableMonitorStreamModificationNotAllowed |
只有在廣播處於 created 或 ready 狀態時,才能修改 contentDetails. 值。 |
forbidden (403) |
recordFromStartModificationNotAllowed |
只有在廣播處於 created 或 ready 狀態時,才能修改 contentDetails. 值。 |
insufficientPermissions |
insufficientLivePermissions |
這項要求未獲授權,無法更新指定的現場直播。詳情請參閱實作 OAuth2 驗證。 |
insufficientPermissions |
liveStreamingNotEnabled |
獲得授權的使用者無法在 YouTube 上串流播放直播影片。如要瞭解詳情,請前往 https://www.youtube.com/features。 |
invalidValue (400) |
invalidAutoStart |
liveBroadcast 資源包含的 contentDetails.enableAutoStart 屬性值無效。您無法修改永久廣播的 enableAutoStart 設定。 |
invalidValue (400) |
invalidAutoStop |
liveBroadcast 資源包含的 contentDetails.enableAutoStop 屬性值無效。您無法修改永久廣播的 enableAutoStop 設定。 |
invalidValue (400) |
invalidDescription |
liveBroadcast 資源並未指定 snippet.description 屬性的有效值。snippet.description 最多可包含 5,000 個字元。 |
invalidValue (400) |
invalidEmbedSetting |
liveBroadcast 資源包含無效的 contentDetails.enable_embed 屬性值。您無法嵌入這個廣播。 |
invalidValue (400) |
invalidEnableClosedCaptions |
在 liveBroadcast 資源中,contentDetails.enableClosedCaptions 屬性的值與 contentDetails.closedCaptionType 設定的值不相容。請修改資源,僅加入其中一種屬性的其中之一,然後重新提交要求。 |
invalidValue (400) |
invalidLatencyPreferenceOptions |
liveBroadcast 資源包含的 contentDetails.latencyPreference 屬性值無效。此延遲時間偏好設定只支援部分設定。
|
invalidValue (400) |
invalidPauseAdsUntil |
liveBroadcast 資源的 monetizationDetails.cuepointSchedule.pauseAdsUntil 屬性含有無效值。這個錯誤可能的原因如下:
|
invalidValue (400) |
invalidPrivacyStatus |
liveBroadcast 資源未指定有效的隱私權狀態。請參閱有效的 privacyStatus 值。 |
invalidValue (400) |
invalidProjection |
liveBroadcast 資源包含無效的 contentDetails.projection 屬性值。永久廣播的投影無法設為 360。 |
invalidValue (400) |
invalidScheduledEndTime |
liveBroadcast 資源包含無效的 snippet.scheduledEndTime 屬性值。排定的結束時間必須晚於排定的開始時間。 |
invalidValue (400) |
invalidScheduledStartTime |
liveBroadcast 資源包含無效的 snippet.scheduledStartTime 屬性值。排定的開始時間必須設在未來。 |
invalidValue (400) |
invalidTitle |
liveBroadcast 資源並未指定 snippet.title 屬性的有效值。snippet.title 長度必須介於 1 到 100 個字元之間。 |
notFound (404) |
liveBroadcastNotFound |
liveBroadcast 資源中指定的 id 屬性無法辨識廣播。 |
required (400) |
broadcastStreamDelayMsRequired |
liveBroadcast 資源並未指定 contentDetails. 屬性。 |
required (400) |
enableMonitorStreamRequired |
liveBroadcast 資源並未指定 contentDetails. 屬性。 |
required (400) |
idRequired |
liveBroadcast 資源必須包含並指定 id 屬性的值。 |
required (400) |
scheduledEndTimeRequired |
liveBroadcast 資源並未指定 snippet.scheduledEndTime 屬性。 |
required (400) |
scheduledStartTimeRequired |
liveBroadcast 資源並未指定 snippet.scheduledStartTime 屬性。 |
試試看!
請使用 APIs Explorer 呼叫這個 API 並查看 API 要求和回應。