更新廣播。舉例來說,您可以修改 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 參數有兩個用途。可用於識別寫入作業將設定的屬性,以及 API 回應會包含的屬性。您可以在參數值中加入的 part 屬性為 id 、snippet 、contentDetails 、monetizationDetails 和 status 。請注意,這個方法會覆寫參數值指定部分內所有可變動屬性的現有值。例如,廣播的隱私權狀態是在 status 部分定義。因此,如果您的要求是更新私人或不公開的廣播訊息,且要求的 part 參數值包含 status 部分,則廣播的隱私權設定會更新為要求主體指定的值。如果要求主體沒有指定值,系統將移除現有的隱私權設定,並還原為預設的隱私權設定。 |
|
選用參數 | ||
onBehalfOfContentOwner |
string 這個參數只能在正確的授權要求中使用。注意:這個參數僅適用於 YouTube 內容合作夥伴。 onBehalfOfContentOwner 參數代表透過要求的授權憑證,代表 YouTube CMS 使用者,代表在參數值中指定的內容擁有者擔任代理人。這個參數適用於擁有及管理多個不同 YouTube 頻道的 YouTube 內容合作夥伴。內容擁有者只要通過一次驗證,即可存取所有影片和頻道資料,不必分別提供各個頻道的驗證憑證。用於驗證的 CMS 帳戶,必須連結至指定的 YouTube 內容擁有者。 |
|
onBehalfOfContentOwnerChannel |
string 這個參數只能在正確的授權要求中使用。這個參數只能在正確授權要求中使用。注意:這個參數僅適用於 YouTube 內容合作夥伴。 onBehalfOfContentOwnerChannel 參數會指定待加入影片的 YouTube 頻道 ID。如果要求指定 onBehalfOfContentOwner 參數值,就必須指定這個參數,且只能搭配該參數使用。此外,該要求都必須使用與 onBehalfOfContentOwner 參數指定的內容擁有者相連結的 CMS 帳戶進行授權。最後,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 要求和回應。