簡介
播放 API 是低延遲 API,用於從網頁或行動應用程式擷取視訊或播放清單資料的用戶端。這是不是用於將 Video Cloud 與您的 CMS 或其他系統集成的通用媒體管理 API - 為此,您應該使用內容管理系統接口 .
過濾Playback API結果以僅返回可播放的視頻(狀態=有效,攝取完成標記= true,以及安排的正確數據/時間)。這意味著即使存在其他再現,播放器也可以在存在一個再現後立即播放視頻。如果您需要獲取當前無法播放的視頻,您應該再次使用內容管理系統接口反而。
還請注意,為了最大程度地提高性能,播放API所訪問的視頻數據會緩存一小段時間。特定數據集ID緩存的時間長短會有所不同,但可能最多20分鐘。
另見API參考 .
使用案例
這Brightcove播放器和Brightcove SDK播放器包括與 Playback API 方法相同的目錄方法,如果您只是在運行時檢索視頻或播放列表以進行播放,則大多數情況下您可以簡單地使用這些方法。
但是,您可能希望在沒有播放器的移動應用程序屏幕中提供視頻或播放列表的視圖。
另外,例如,有時您可能想在不讓播放器出現在屏幕上的情況下檢索視頻或播放列表以顯示有關它們的信息,例如,作為視頻門戶的登錄頁面。
在這些情況下,播放API很有用。
一般資訊
基本網址
Playback API的基本URL為:
https://edge.api.brightcove.com/playback/v1
帳號路徑
在所有情況下,我們都會針對特定的視訊雲端帳戶提出要求。因此,您將始終添加術語accounts
然後是您的帳戶 ID 到基本 URL:
https://edge.api.brightcove.com/playback/v1/accounts/{account_id}
驗證
原則金鑰可透過下列三種方式之一傳遞要求進行驗證:
- 在一個爭論中
Accept
標頭:Accept: application/json;pk={policy_key}
這是基於瀏覽器的客戶端的推薦方法,因為它允許請求繼續,而不需要額外的請求作為瀏覽器 CORS「預飛行」檢查的一部分。這樣可在第一次提出瀏覽器要求時節省延遲。
- 在一個
Authorization
使用 realm 關鍵字的標頭BCOV-Policy
:Authorization: BCOV-Policy {policy_key}
- 在一個
BCOV-Policy
標頭:BCOV-Policy: {policy_key}
取得原則金鑰
您可以通過三種方式獲取策略密鑰:
權杖驗證
支持HLS和DASH內容的令牌身份驗證。如果您需要令牌身份驗證,請聯繫您的客戶成功經理以了解為您的帳戶啟用它。
避免使用硬編碼的網址
縮圖、海報、影片檔案和其他媒體的網址絕對不能在您的網頁或應用程式中進行硬式編碼。這Playback API將返回媒體文件 URL 的最新緩存版本,但 URL 本身可能會發生變化。你應該使用CMS API( 或者Playback API ) 請求在每次加載頁面時檢索這些 URL,或者將它們緩存不超過六個小時。
快取視訊和圖片 URL
您可以快取視訊和影像的 URL,以改善頁面效能,但是必須定期重新整理快取。如果您快取擷取的 URL 以改善網頁效能,請務必每六小時重複一次 API 呼叫來重新整理快取。
方法
API僅支持以下類型的以下GET請求:
影片要求
可以使用視頻ID或參考ID檢索單個視頻對象。
通過ID獲取視頻
端點
https://edge.api.brightcove.com/playback/v1/accounts/{account_id}/videos/{video_id}
範例
https://edge.api.brightcove.com/playback/v1/accounts/57838016001/videos/38467382999
範例回應
{
"account_id": "107767373999",
"ad_keys": null,
"created_at": "2010-07-12T22:37:34.760Z",
"description": "Avatar_MakingAScene_Featurette",
"duration": 595560,
"id": "38467382999",
"long_description": null,
"name": "Avatar_MakingAScene_Featurette",
"published_at": "2010-07-12T22:37:34.760Z",
"reference_id": "AvatarMakingShort",
"text_tracks": [],
"updated_at": "2010-07-12T22:54:29.666Z",
"cue_points": [
{
"id": "111637107001",
"name": "Pre-roll",
"type": "AD",
"time": 0,
"metadata": null,
"force_stop": false
}
],
"custom_fields": {
"moretext": "this is the first video uploaded",
"mylist": "abc"
},
"link": {
"text": "Full Dvd at Amazon",
"url": "https://www.amazon.com/Avatar-Sam-Worthington/dp/B002VPE1AW"
},
"tags": [
"copied"
],
"poster_sources": [
{
"src": "https://brightcove04.o.brightcove.com/107767373999/107767373999_111728861001_vs-111727994001.jpg?pubId=107767373999&videoId=38467382999"
}
],
"thumbnail_sources": [
{
"src": "https://brightcove04.o.brightcove.com/107767373999/107767373999_111728862001_th-111727994001.jpg?pubId=107767373999&videoId=38467382999"
}
],
"poster": "https://brightcove04.o.brightcove.com/107767373999/107767373999_111728861001_vs-111727994001.jpg?pubId=107767373999&videoId=38467382999",
"thumbnail": "https://brightcove04.o.brightcove.com/107767373999/107767373999_111728862001_th-111727994001.jpg?pubId=107767373999&videoId=38467382999",
"sources": [
{
"avg_bitrate": 379000,
"width": 320,
"duration": 595560,
"size": 28196307,
"stream_name": "mp4:107767373999/107767373999_111728840001_Avatar-MakingAScene-Featurette.mp4?__nn__=1497926354001&slist=107767373999/&auth=daEciavcicRbhbtdSaBdBdVbXd0aUdTcMaX-bvRrSa-hca-slyCzrux_zJAq_HFCB_EvE&aifp=bcosuds",
"codec": "H264",
"asset_id": "111728840001",
"container": "MP4",
"height": 180,
"app_name": "rtmp://cp150446.edgefcs.net/ondemand"
},
{
"avg_bitrate": 379000,
"width": 320,
"src": "https://uds.ak.o.brightcove.com/107767373999/107767373999_111728840001_Avatar-MakingAScene-Featurette.mp4?pubId=107767373999&videoId=38467382999",
"size": 28196307,
"height": 180,
"duration": 595560,
"container": "MP4",
"codec": "H264",
"asset_id": "111728840001"
}, ... 6 more sources ...
]
}
通過參考ID獲取視頻
端點
https://edge.api.brightcove.com/playback/v1/accounts/{account_id}/videos/ref:{reference_id}
範例
https://edge.api.brightcove.com/playback/v1/accounts/57838016001/videos/ref:nature_2010-07-12
範例回應
{
"account_id": "107767373999",
"ad_keys": null,
"created_at": "2010-07-12T22:37:34.760Z",
"description": "Avatar_MakingAScene_Featurette",
"duration": 595560,
"id": "38467382999",
"long_description": null,
"name": "Avatar_MakingAScene_Featurette",
"published_at": "2010-07-12T22:37:34.760Z",
"reference_id": "nature_2010-07-12",
"text_tracks": [],
"updated_at": "2010-07-12T22:54:29.666Z",
"cue_points": [
{
"id": "111637107001",
"name": "Pre-roll",
"type": "AD",
"time": 0,
"metadata": null,
"force_stop": false
}
],
"custom_fields": {
"moretext": "this is the first video uploaded",
"mylist": "abc"
},
"link": {
"text": "Full Dvd at Amazon",
"url": "https://www.amazon.com/Avatar-Sam-Worthington/dp/B002VPE1AW"
},
"tags": [
"copied"
],
"poster_sources": [
{
"src": "https://brightcove04.o.brightcove.com/107767373999/107767373999_111728861001_vs-111727994001.jpg?pubId=107767373999&videoId=38467382999"
}
],
"thumbnail_sources": [
{
"src": "https://brightcove04.o.brightcove.com/107767373999/107767373999_111728862001_th-111727994001.jpg?pubId=107767373999&videoId=38467382999"
}
],
"poster": "https://brightcove04.o.brightcove.com/107767373999/107767373999_111728861001_vs-111727994001.jpg?pubId=107767373999&videoId=38467382999",
"thumbnail": "https://brightcove04.o.brightcove.com/107767373999/107767373999_111728862001_th-111727994001.jpg?pubId=107767373999&videoId=38467382999",
"sources": [
{
"avg_bitrate": 379000,
"width": 320,
"duration": 595560,
"size": 28196307,
"stream_name": "mp4:107767373999/107767373999_111728840001_Avatar-MakingAScene-Featurette.mp4?__nn__=1497926354001&slist=107767373999/&auth=daEciavcicRbhbtdSaBdBdVbXd0aUdTcMaX-bvRrSa-hca-slyCzrux_zJAq_HFCB_EvE&aifp=bcosuds",
"codec": "H264",
"asset_id": "111728840001",
"container": "MP4",
"height": 180,
"app_name": "rtmp://cp150446.edgefcs.net/ondemand"
},
{
"avg_bitrate": 379000,
"width": 320,
"src": "https://uds.ak.o.brightcove.com/107767373999/107767373999_111728840001_Avatar-MakingAScene-Featurette.mp4?pubId=107767373999&videoId=38467382999",
"size": 28196307,
"height": 180,
"duration": 595560,
"container": "MP4",
"codec": "H264",
"asset_id": "111728840001"
}, ... 6 more sources ...
]
}
搜尋影片
你必須使用啟用搜索的策略密鑰 , 在使用 Playback API 搜索視頻時。有關詳細信息,請參閱播放 API 參考文檔。
參數
請注意,所有參數都是選修的 .他們適用於GET Videos
僅請求。
參數 | 描述 |
---|---|
q |
用於搜索的查詢字符串 - 有關詳細信息,請參閱搜索指南 |
limit |
要返回的視頻數 - 必須是 1 到 1000 之間的整數。預設值: 20 |
offset |
要跳過的視訊數目 (用於分頁結果)。必須是正整數。預設值: 0 |
sort |
字串;指定要排序依據的欄位。 從...開始 - 降序排序。如果一個值 q 提供,那麼默認排序是按“分數”(搜索結果與原始查詢的相關性)。如果沒有價值 q 提供了,則默認排序方式為updated_at 下降。以下字段對排序有效: name , reference_id , created_at , published_at , updated_at , schedule_starts_at , schedule_ends_at , state , plays_total , 和plays_trailing_week 有關詳細信息,請參閱獲取視頻回放 API 參考部分 |
config_id |
請參閱 交付規則 |
ad_config_id |
請參閱 使用 SSAI 的視頻請求 |
使用搜索參數
Brightcove的Playback API提供了一種程序化的方式來搜索您的視頻Video Cloud 圖書館。
要對視頻數據執行基本和復雜的搜索,您將使用q
範圍:
https://edge.api.brightcove.com/playback/v1/accounts/1752604051111/videos?q={search terms}
有關如何搜索視頻的詳細信息,請參閱搜索影片文檔。
分頁結果
使用limit
參數指定您希望在請求中返回多少項目 - 最多 1000。然後您可以使用offset
參數對大於的結果集進行分頁limit
.這offset
是要跳過的項目數。
例如,假設總結果集至少有 75 部影片,下列搜尋會傳回總結果集的 51-75 部影片:
/videos?q=updated_at:2014-01-01..2014-06-30&limit=25&offset=50
這limit
和offset
參數只能用於視頻。
分頁最佳做法
從Playback API分頁結果集時,建議遵循以下步驟:
- 使用
limit
和offset
參數從結果集中返回數據組。/accounts/578380111111/videos?q=tags:nature&limit=20&offset=50
- 對於每個響應,您將看到
count
字段始終顯示結果集中的最大視頻數。{"count": 171, "videos": [ ... ] }
- 總數
count
您第一個請求中的視頻數量可用於確定您還需要請求多少頁。
或者,您可以詢問count
每個響應的值並繼續直到count
小於或等於頁面大小乘以limit
.count <= page-number * limit
排序視訊結果
使用參數sort=field_name
指定結果的排序方式。您可以對以下視頻字段進行排序: [1-1]
- 名稱
- 參照 _ 識別碼
- 建立
- 發佈時
- 更新 (_S)
- schedule_starts_at(注意:這是種類領域 - 的搜索字段是
schedule.starts_at
) - schedule_ends_at(注意:這是種類領域 - 的搜索字段是
schedule.ends_at
) - 狀態
- 總播放次數[1-2]
- plays_trailing_week [1-2]
注意事項
- [1-1]如果您沒有為視頻搜索呼叫提供排序值,結果將按相關性排序。如果您不提供排序值
GET
視頻通話,結果將按updated_at
下降。 - [1-2]你可以排序
plays_total
或者plays_trailing_week
, 但這些字段不包含在結果中
所有視訊和大型資料集
如果您要擷取帳戶中的所有影片或大量影片,您必須注意以下幾點:
- 您可能會想使用允許的最大
limit
(1000),但最好以 25 個或更少的批次檢索視頻,以盡量減少 API 請求超時的可能性 - 當您通過大型數據集進行分頁時,可能會在操作過程中更新視頻數據,這可能會導致項目在響應中轉移:
- 您可能會在連續的頁面上看到重複的項目
- 某個項目可能會遺漏,因為它已經轉移到先前的回應集
為了考慮第一種可能性,您的應用程序應該在您完成檢索視頻後解除重複刪除完整的項目列表。為了處理第二種可能性,您需要將檢索到的項目總數(在刪除重製之後)與您期望的數字進行比較,然後重新運行請求,按照 last_modified_date(降序)排序結果-您不應該需要檢索多個批次來拾取錯過的項目。
- 您可以藉由適當地排序傳回的結果,以減少上一個項目中案例的可能性。默認排序依據關聯 for searches 基於一種複雜的算法,該算法會查找關鍵字、標籤和自定義字段值的組合。如果您是根據多個關鍵字、標籤和/或自訂欄位來搜尋影片,請依關聯性排序就是您想要的。但是,如果您只是想檢索全部或大量視頻,請將
sort
顯式參數將使您更好地控制返回項目的順序。
取得影片
端點
https://edge.api.brightcove.com/playback/v1/accounts/{account_id}/videos
範例
https://edge.api.brightcove.com/playback/v1/accounts/57838016001/videos?q=tags:nature,name:nature
範例回應
{
"count": 123,
"videos":
[
{<video1 fields>},
{<video2 fields>},
...
]
}
錯誤回應
如果您嘗試將“獲取視頻”端點與未啟用搜索的策略密鑰一起使用,則會從Playback API收到以下錯誤消息:
[
{
"api_call": "search",
"error_subcode": "API",
"error_code": "ACCESS_DENIED",
"message": "Access to this resource is forbidden by access policy."
}
]
查找相關視頻
通過Playback API,您可以在帳戶中搜索與指定視頻相關的視頻。基於name
和short description
對於指定的視頻,API 將在以下字段中搜索任何部分匹配項:
name
short description
long description
tags
如果地理限制生效,則可能不會收到整頁的結果。
參數
以下URL參數可用於GET相關視頻請求:
參數 | 描述 |
---|---|
limit |
要返回的視頻數(默認值=20;最大值=1000) |
ad_config_id |
附加您的 ad_config_id 以返回帶 SSAI 的視頻 |
默認情況下,響應最多包含20個視頻。您可以使用limit
參數最多可返回 1000 個視頻,但會增加延遲。
請注意,沒有offset
查找相關視頻時的參數,因此您將無法翻閱視頻結果。
使用視頻ID獲取相關視頻
端點
https://edge.api.brightcove.com/playback/v1/accounts/{account_id}/videos/{video_id}/related
範例
https://edge.api.brightcove.com/playback/v1/accounts/1752604059001/videos/5565662146001/related
使用參考ID獲取相關視頻
端點
https://edge.api.brightcove.com/playback/v1/accounts/{account_id}/videos/ref:{reference_id}/related
範例
https://edge.api.brightcove.com/playback/v1/accounts/1752604059001/videos/ref:nature/related
範例回應
在下面的回復中,請注意沒有count
場,不同於搜索視頻回复。
{
"videos":
[
{<video1 fields>},
{<video2 fields>},
...
]
}
錯誤回應
如果您嘗試通過未啟用搜索的策略密鑰使用與查找相關的終結點,則會從Playback API收到以下錯誤消息:
[
{
"api_call": "search",
"error_subcode": "API",
"error_code": "ACCESS_DENIED",
"message": "Access to this resource is forbidden by access policy."
}
]
發貨規則
要將傳送規則應用於對 Playback API 請求的響應,請附加config_id={DELIVERY_RULES_ID}
到請求。
範例
https://edge.api.brightcove.com/playback/v1/accounts/1752604059001/videos/6026822730001?config_id=9869b9f8-59a1-4490-a092-c28b6cf79764
使用SSAI的視頻請求
即使您沒有在應用程序中使用Brightcove Web播放器或Brightcove Native SDK,您仍然可以在自己的播放器中使用服務器端廣告插入(SSAI)。
使用SSAI獲取視頻
要返回具有SSAI的視頻,請將您的廣告配置ID作為URL參數附加到您的Playback API請求中。通過此請求,您可以使用視頻ID或視頻參考ID。
-
附加你的
ad_config_id
到 Playback API 請求的末尾:帶有 URL 參數的端點
https://edge.api.brightcove.com/playback/v1/accounts/{account_id}/videos/{video_id}?ad_config_id={ad_config_id}
例子
https://edge.api.brightcove.com/playback/v1/accounts/1752604059001/videos/5565662146001?ad_config_id=1234abcd
-
在下面的示例響應中,您將注意到以下內容:
- 響應類似於如果未包含廣告配置ID的響應。
- 的元素
sources
array 將包含一個名為的新屬性vmap
. - 如果您想知道廣告在內容中的位置,您可以閱讀鏈接中的 VMAP 文件
vmap
財產。
回放 API 響應示例
{ "description": "The story of a giant rabbit with a heart bigger than himself. ", "poster_sources": [ { "src": "https://cf-images.us-east-1.prod.boltdns.net/v1/jit/3723496277001/dd5bd69c-e962-4a43-9dbd-94faaaba1785/main/1280x720/5m17s130ms/match/image.jpg" } ], "tags": [], "cue_points": [], "custom_fields": {}, "account_id": "3723496277001", "sources": [ { "ext_x_version": "4", "vmap": "https://ssaiplayback.prod.boltdns.net/playback/once/v1/vmap/hls/v4/clear/3723496277001/7a3316d9-1b06-4d62-bec8-3919b43fffbb/dd5bd69c-e962-4a43-9dbd-94faaaba1785/content.vmap?bc_token=NTllMTMxYjNfMTdkOTY2YThhNjU5MDk5ZTQ3NDBkNmUxOTYyOGRkNzM0ZjBiM2RjMGEwOThjOGFkYjk1MWQxMzFmNGYzMjA5YQ%3D%3D", "type": "application/x-mpegURL", "src": "https://ssaiplayback.prod.boltdns.net/playback/once/v1/hls/v4/clear/3723496277001/7a3316d9-1b06-4d62-bec8-3919b43fffbb/dd5bd69c-e962-4a43-9dbd-94faaaba1785/master.m3u8?bc_token=NTllMTMxYjNfZGM5ZDg0NGM2ZGJjZDcxZTFjOGYyODBlMzM2NmNmMmJkMWNhZDczNWViNzRiMjIwNjg5MjkzZGM0ZmJlMTc1Yw%3D%3D" }, ... ], "created_at": "2017-05-15T17:09:11.171Z" }
- 複製其中一個
vmap
URL 並將其粘貼到瀏覽器搜索欄中以查看 VMAP 響應。 -
VMAP 響應包含
<bc:Brightcove
標記為contenturi
屬性。這是您應該用來加載播放器的 URL。示例 VMAP 響應
以下是 vmap 響應的示例:
<vmap:VMAP xmlns:bc="bc" xmlns:vmap="https://www.iab.net/vmap-1.0" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" version="1.0"> <vmap:Extensions> <bc:Brightcove ttl="3600" contenturi="https://ssaimanifest.prod.boltdns.net/us-east-1/playback/once/v1/hls/v4/clear/1752604059001/d6190656-2095-4ff3-8afe-1a0b60d67ed2/dca41ae8-d8f5-48a6-9853-564764d60b84/6830b2e4-3298-439d-beef-e04abef9f23c/content.m3u8?bc_token=NWZkMTE5NTlfZWQxNDAzNDRkNTAxNDRlMWEwODU3MTI1MzY2YjAyZWQ5YzlmZTkzY2UwMjM5NTM1MmI2NGRjZDNhNjE2ZDhlOA%3D%3D" contentlength="24.0574" payloadlength="50.1835" contenttype="application/x-mpegURL" /> <bc:thumbnailURL type="thumbnail" width="480" height="270" bandwidth="0">https://ssai.playback.us-east-1.prod.deploys.brightcove.com/v1/thumbnail/1752604059001/dca41ae8-d8f5-48a6-9853-564764d60b84/low-res/6830b2e4-3298-439d-beef-e04abef9f23c/thumbnail.vtt?bc_token=NWZkMTE5NTlfMmVmODIzZDJjMGZkMDBjZjY1YWIxNDQ4Y2YyZmUxYTExNzg5YmIxZDI5ZTdkMjgyODBmMDBmYTViMTE2Yzc0MQ%3D%3D</bc:thumbnailURL> </vmap:Extensions> <vmap:AdBreak breakType="linear" breakId="PreRoll_0_0" timeOffset="start"> <vmap:AdSource allowMultipleAds="true" followRedirects="true" id="0"> <vmap:VASTData> <VAST xmlns:xsd="https://www.w3.org/2001/XMLSchema" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"> <Ad id="1"> <InLine> <AdSystem>Test Ad Server</AdSystem> <AdTitle>Portals</AdTitle> <Description>Demo ad number 6</Description> <Error></Error> <Creatives> <Creative> <Linear> <CreativeExtensions> <CreativeExtension> <BrightcoveForeignKey>1</BrightcoveForeignKey> </CreativeExtension> </CreativeExtensions> <Duration>00:00:05.9392</Duration> <AdParameters> <xml></xml> </AdParameters> <VideoClicks/> </Linear> </Creative> </Creatives> <Extensions> <Extension> <xml>data</xml> </Extension> </Extensions> </InLine> </Ad> </VAST> </vmap:VASTData> </vmap:AdSource> </vmap:AdBreak> <vmap:AdBreak breakType="linear" breakId="MidRoll_5_0" timeOffset="00:00:04.8381"> <vmap:AdSource allowMultipleAds="true" followRedirects="true" id="1"> <vmap:VASTData> <VAST xmlns:xsd="https://www.w3.org/2001/XMLSchema" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"> <Ad id="2"> <InLine> <AdSystem>Test Ad Server</AdSystem> <AdTitle>Marketing</AdTitle> <Description>Demo ad number 4</Description> <Error></Error> <Creatives> <Creative> <Linear skipoffset="00:00:05"> <CreativeExtensions> <CreativeExtension> <BrightcoveForeignKey>2</BrightcoveForeignKey> </CreativeExtension> </CreativeExtensions> <Duration>00:00:12.1788</Duration> <AdParameters> <xml></xml> </AdParameters> <VideoClicks/> </Linear> </Creative> </Creatives> <Extensions> <Extension> <xml>data</xml> </Extension> </Extensions> </InLine> </Ad> </VAST> </vmap:VASTData> </vmap:AdSource> </vmap:AdBreak> <vmap:AdBreak breakType="linear" breakId="PostRoll_24_0" timeOffset="end"> <vmap:AdSource allowMultipleAds="true" followRedirects="true" id="2"> <vmap:VASTData> <VAST xmlns:xsd="https://www.w3.org/2001/XMLSchema" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"> <Ad id="3"> <InLine> <AdSystem>Test Ad Server</AdSystem> <AdTitle>Brand</AdTitle> <Description>Demo ad number 1</Description> <Error></Error> <Creatives> <Creative> <Linear> <CreativeExtensions> <CreativeExtension> <BrightcoveForeignKey>3</BrightcoveForeignKey> </CreativeExtension> </CreativeExtensions> <Duration>00:00:08.0080</Duration> <AdParameters> <xml></xml> </AdParameters> <VideoClicks/> </Linear> </Creative> </Creatives> <Extensions> <Extension> <xml>data</xml> </Extension> </Extensions> </InLine> </Ad> </VAST> </vmap:VASTData> </vmap:AdSource> </vmap:AdBreak> </vmap:VMAP>
有關詳細信息,請參閱 使用非 Brightcove 播放器和 SDK 文檔實施 SSAI 。
配置播放器
需要ad_config_id
使用策略 API,您可以創建一個策略密鑰,要求您包含ad_config_id
向 Playback API 發出請求時的 URL 參數。有關設置此功能的詳細信息,請參閱策略 API 參考文檔。
當策略鍵設置為需要ad_config_id
,並且您不將其附加到 Playback API 請求,您將收到以下錯誤:
[
{
"error_subcode": "AD_CONFIG",
"error_code": "ACCESS_DENIED",
"message": "Missing required ad_config_id parameter"
}
]
播放清單要求
可以使用播放列表ID或其參考ID來檢索播放列表視頻對象。
播放列表最多可包含 1000 個視頻,但默認情況下,僅返回前 20 個。使用下面描述的參數,您一次最多可以返回 1000 個視頻,或者使用更小的limit
並使用offset
參數來檢索您想要的視頻組,或提交多個請求以將它們全部返回。
參數
以下網址參數可用於播放列表請求
參數 | 描述 |
---|---|
限制 | 要返回的視頻數(默認值=20;最大值=1000) |
抵消 | 要跳過的視頻數(從播放列表的開頭;默認= 0) |
例如,這些參數附加到您的請求 - ?limit=100& offset=200 - 將返回播放列表中的視頻 201-300(假設有那麼多)。
通過ID獲取播放列表
端點
https://edge.api.brightcove.com/playback/v1/accounts/{account_id}/playlists/{playlist_id}
範例
https://edge.api.brightcove.com/playback/v1/accounts/57838016001/playlists/38467382999
範例回應
{
"account_id": "107767373999",
"created_at": "2010-07-12T22:43:30.290Z",
"description": null,
"id": "111592530001",
"name": "Play One",
"reference_id": null,
"type": "EXPLICIT",
"updated_at": "2010-07-12T22:51:25.055Z",
"videos": [
{
"description": "Avatar_MakingAScene_Featurette",
"poster_sources": [
{
"src": "https://brightcove04.o.brightcove.com/107767373999/107767373999_111728861001_vs-111727994001.jpg?pubId=107767373999&videoId=38467382999"
}
],
"tags": [
"copied"
],
"cue_points": [
{
"id": "111637107001",
"name": "Pre-roll",
"type": "AD",
"time": 0,
"metadata": null,
"force_stop": false
}
],
"custom_fields": {
"moretext": "this is the first video uploaded",
"mylist": "abc"
},
"account_id": "107767373999",
"sources": [
{
"avg_bitrate": 379000,
"width": 320,
"duration": 595560,
"size": 28196307,
"stream_name": "mp4:107767373999/107767373999_111728840001_Avatar-MakingAScene-Featurette.mp4?__nn__=1497926354001&slist=107767373999/&auth=daEciavcicRbhbtdSaBdBdVbXd0aUdTcMaX-bvRrSa-hca-slyCzrux_zJAq_HFCB_EvE&aifp=bcosuds",
"codec": "H264",
"asset_id": "111728840001",
"container": "MP4",
"height": 180,
"app_name": "rtmp://cp150446.edgefcs.net/ondemand"
},
{
"avg_bitrate": 379000,
"width": 320,
"src": "https://uds.ak.o.brightcove.com/107767373999/107767373999_111728840001_Avatar-MakingAScene-Featurette.mp4?pubId=107767373999&videoId=38467382999",
"size": 28196307,
"height": 180,
"duration": 595560,
"container": "MP4",
"codec": "H264",
"asset_id": "111728840001"
},
{
"avg_bitrate": 267000,
"width": 320,
"duration": 595560,
"size": 19894997,
"stream_name": "mp4:107767373999/107767373999_111728852001_Avatar-MakingAScene-Featurette.mp4?__nn__=1497926354001&slist=107767373999/&auth=daEciavcicRbhbtdSaBdBdVbXd0aUdTcMaX-bvRrSa-hca-slyCzrux_zJAq_HFCB_EvE&aifp=bcosuds",
"codec": "H264",
"asset_id": "111728852001",
"container": "MP4",
"height": 180,
"app_name": "rtmp://cp150446.edgefcs.net/ondemand"
},
{
"avg_bitrate": 267000,
"width": 320,
"src": "https://uds.ak.o.brightcove.com/107767373999/107767373999_111728852001_Avatar-MakingAScene-Featurette.mp4?pubId=107767373999&videoId=38467382999",
"size": 19894997,
"height": 180,
"duration": 595560,
"container": "MP4",
"codec": "H264",
"asset_id": "111728852001"
},
{
"avg_bitrate": 549000,
"width": 480,
"duration": 595567,
"size": 40889436,
"stream_name": "mp4:107767373999/107767373999_111728860001_Avatar-MakingAScene-Featurette.mp4?__nn__=1497926354001&slist=107767373999/&auth=daEciavcicRbhbtdSaBdBdVbXd0aUdTcMaX-bvRrSa-hca-slyCzrux_zJAq_HFCB_EvE&aifp=bcosuds",
"codec": "H264",
"asset_id": "111728860001",
"container": "MP4",
"height": 268,
"app_name": "rtmp://cp150446.edgefcs.net/ondemand"
},
{
"avg_bitrate": 549000,
"width": 480,
"src": "https://uds.ak.o.brightcove.com/107767373999/107767373999_111728860001_Avatar-MakingAScene-Featurette.mp4?pubId=107767373999&videoId=38467382999",
"size": 40889436,
"height": 268,
"duration": 595567,
"container": "MP4",
"codec": "H264",
"asset_id": "111728860001"
},
{
"avg_bitrate": 835000,
"width": 640,
"duration": 595567,
"size": 62142992,
"stream_name": "mp4:107767373999/107767373999_111728865001_Avatar-MakingAScene-Featurette.mp4?__nn__=1497926354001&slist=107767373999/&auth=daEciavcicRbhbtdSaBdBdVbXd0aUdTcMaX-bvRrSa-hca-slyCzrux_zJAq_HFCB_EvE&aifp=bcosuds",
"codec": "H264",
"asset_id": "111728865001",
"container": "MP4",
"height": 360,
"app_name": "rtmp://cp150446.edgefcs.net/ondemand"
},
{
"avg_bitrate": 835000,
"width": 640,
"src": "https://uds.ak.o.brightcove.com/107767373999/107767373999_111728865001_Avatar-MakingAScene-Featurette.mp4?pubId=107767373999&videoId=38467382999",
"size": 62142992,
"height": 360,
"duration": 595567,
"container": "MP4",
"codec": "H264",
"asset_id": "111728865001"
},
{
"avg_bitrate": 1744000,
"width": 640,
"duration": 595567,
"size": 129836869,
"stream_name": "mp4:107767373999/107767373999_111735357001_Avatar-MakingAScene-Featurette.mp4?__nn__=1497926354001&slist=107767373999/&auth=daEciavcicRbhbtdSaBdBdVbXd0aUdTcMaX-bvRrSa-hca-slyCzrux_zJAq_HFCB_EvE&aifp=bcosuds",
"codec": "H264",
"asset_id": "111735357001",
"container": "MP4",
"height": 360,
"app_name": "rtmp://cp150446.edgefcs.net/ondemand"
},
{
"avg_bitrate": 1744000,
"width": 640,
"src": "https://uds.ak.o.brightcove.com/107767373999/107767373999_111735357001_Avatar-MakingAScene-Featurette.mp4?pubId=107767373999&videoId=38467382999",
"size": 129836869,
"height": 360,
"duration": 595567,
"container": "MP4",
"codec": "H264",
"asset_id": "111735357001"
},
{
"avg_bitrate": 1249000,
"width": 640,
"duration": 595567,
"size": 92994065,
"stream_name": "mp4:107767373999/107767373999_111735369001_Avatar-MakingAScene-Featurette.mp4?__nn__=1497926354001&slist=107767373999/&auth=daEciavcicRbhbtdSaBdBdVbXd0aUdTcMaX-bvRrSa-hca-slyCzrux_zJAq_HFCB_EvE&aifp=bcosuds",
"codec": "H264",
"asset_id": "111735369001",
"container": "MP4",
"height": 360,
"app_name": "rtmp://cp150446.edgefcs.net/ondemand"
},
{
"avg_bitrate": 1249000,
"width": 640,
"src": "https://uds.ak.o.brightcove.com/107767373999/107767373999_111735369001_Avatar-MakingAScene-Featurette.mp4?pubId=107767373999&videoId=38467382999",
"size": 92994065,
"height": 360,
"duration": 595567,
"container": "MP4",
"codec": "H264",
"asset_id": "111735369001"
}
],
"name": "Avatar_MakingAScene_Featurette",
"reference_id": "AvatarMakingShort",
"long_description": null,
"duration": 595560,
"published_at": "2010-07-12T22:37:34.760Z",
"text_tracks": [],
"updated_at": "2010-07-12T22:54:29.666Z",
"thumbnail": "https://brightcove04.o.brightcove.com/107767373999/107767373999_111728862001_th-111727994001.jpg?pubId=107767373999&videoId=38467382999",
"poster": "https://brightcove04.o.brightcove.com/107767373999/107767373999_111728861001_vs-111727994001.jpg?pubId=107767373999&videoId=38467382999",
"link": {
"text": "Full Dvd at Amazon",
"url": "https://www.amazon.com/Avatar-Sam-Worthington/dp/B002VPE1AW"
},
"id": "38467382999",
"ad_keys": null,
"thumbnail_sources": [
{
"src": "https://brightcove04.o.brightcove.com/107767373999/107767373999_111728862001_th-111727994001.jpg?pubId=107767373999&videoId=38467382999"
}
],
"created_at": "2010-07-12T22:37:34.760Z"
}
],
}
通過參考ID獲取播放列表
端點
https://edge.api.brightcove.com/playback/v1/accounts/{account_id}/playlists/ref:{reference_id}
範例
https://edge.api.brightcove.com/playback/v1/accounts/57838016001/playlists/ref:nature_2010-07-12
範例回應
{
"account_id": "107767373999",
"created_at": "2010-07-12T22:43:30.290Z",
"description": null,
"id": "111592530001",
"name": "Play One",
"reference_id": nature_2010-07-12,
"type": "EXPLICIT",
"updated_at": "2010-07-12T22:51:25.055Z",
"videos": [
{
"description": "Avatar_MakingAScene_Featurette",
"poster_sources": [
{
"src": "https://brightcove04.o.brightcove.com/107767373999/107767373999_111728861001_vs-111727994001.jpg?pubId=107767373999&videoId=38467382999"
}
],
"tags": [
"copied"
],
"cue_points": [
{
"id": "111637107001",
"name": "Pre-roll",
"type": "AD",
"time": 0,
"metadata": null,
"force_stop": false
}
],
"custom_fields": {
"moretext": "this is the first video uploaded",
"mylist": "abc"
},
"account_id": "107767373999",
"sources": [
{
"avg_bitrate": 379000,
"width": 320,
"duration": 595560,
"size": 28196307,
"stream_name": "mp4:107767373999/107767373999_111728840001_Avatar-MakingAScene-Featurette.mp4?__nn__=1497926354001&slist=107767373999/&auth=daEciavcicRbhbtdSaBdBdVbXd0aUdTcMaX-bvRrSa-hca-slyCzrux_zJAq_HFCB_EvE&aifp=bcosuds",
"codec": "H264",
"asset_id": "111728840001",
"container": "MP4",
"height": 180,
"app_name": "rtmp://cp150446.edgefcs.net/ondemand"
},
{
"avg_bitrate": 379000,
"width": 320,
"src": "https://uds.ak.o.brightcove.com/107767373999/107767373999_111728840001_Avatar-MakingAScene-Featurette.mp4?pubId=107767373999&videoId=38467382999",
"size": 28196307,
"height": 180,
"duration": 595560,
"container": "MP4",
"codec": "H264",
"asset_id": "111728840001"
},
{
"avg_bitrate": 267000,
"width": 320,
"duration": 595560,
"size": 19894997,
"stream_name": "mp4:107767373999/107767373999_111728852001_Avatar-MakingAScene-Featurette.mp4?__nn__=1497926354001&slist=107767373999/&auth=daEciavcicRbhbtdSaBdBdVbXd0aUdTcMaX-bvRrSa-hca-slyCzrux_zJAq_HFCB_EvE&aifp=bcosuds",
"codec": "H264",
"asset_id": "111728852001",
"container": "MP4",
"height": 180,
"app_name": "rtmp://cp150446.edgefcs.net/ondemand"
},
{
"avg_bitrate": 267000,
"width": 320,
"src": "https://uds.ak.o.brightcove.com/107767373999/107767373999_111728852001_Avatar-MakingAScene-Featurette.mp4?pubId=107767373999&videoId=38467382999",
"size": 19894997,
"height": 180,
"duration": 595560,
"container": "MP4",
"codec": "H264",
"asset_id": "111728852001"
},
{
"avg_bitrate": 549000,
"width": 480,
"duration": 595567,
"size": 40889436,
"stream_name": "mp4:107767373999/107767373999_111728860001_Avatar-MakingAScene-Featurette.mp4?__nn__=1497926354001&slist=107767373999/&auth=daEciavcicRbhbtdSaBdBdVbXd0aUdTcMaX-bvRrSa-hca-slyCzrux_zJAq_HFCB_EvE&aifp=bcosuds",
"codec": "H264",
"asset_id": "111728860001",
"container": "MP4",
"height": 268,
"app_name": "rtmp://cp150446.edgefcs.net/ondemand"
},
{
"avg_bitrate": 549000,
"width": 480,
"src": "https://uds.ak.o.brightcove.com/107767373999/107767373999_111728860001_Avatar-MakingAScene-Featurette.mp4?pubId=107767373999&videoId=38467382999",
"size": 40889436,
"height": 268,
"duration": 595567,
"container": "MP4",
"codec": "H264",
"asset_id": "111728860001"
},
{
"avg_bitrate": 835000,
"width": 640,
"duration": 595567,
"size": 62142992,
"stream_name": "mp4:107767373999/107767373999_111728865001_Avatar-MakingAScene-Featurette.mp4?__nn__=1497926354001&slist=107767373999/&auth=daEciavcicRbhbtdSaBdBdVbXd0aUdTcMaX-bvRrSa-hca-slyCzrux_zJAq_HFCB_EvE&aifp=bcosuds",
"codec": "H264",
"asset_id": "111728865001",
"container": "MP4",
"height": 360,
"app_name": "rtmp://cp150446.edgefcs.net/ondemand"
},
{
"avg_bitrate": 835000,
"width": 640,
"src": "https://uds.ak.o.brightcove.com/107767373999/107767373999_111728865001_Avatar-MakingAScene-Featurette.mp4?pubId=107767373999&videoId=38467382999",
"size": 62142992,
"height": 360,
"duration": 595567,
"container": "MP4",
"codec": "H264",
"asset_id": "111728865001"
},
{
"avg_bitrate": 1744000,
"width": 640,
"duration": 595567,
"size": 129836869,
"stream_name": "mp4:107767373999/107767373999_111735357001_Avatar-MakingAScene-Featurette.mp4?__nn__=1497926354001&slist=107767373999/&auth=daEciavcicRbhbtdSaBdBdVbXd0aUdTcMaX-bvRrSa-hca-slyCzrux_zJAq_HFCB_EvE&aifp=bcosuds",
"codec": "H264",
"asset_id": "111735357001",
"container": "MP4",
"height": 360,
"app_name": "rtmp://cp150446.edgefcs.net/ondemand"
},
{
"avg_bitrate": 1744000,
"width": 640,
"src": "https://uds.ak.o.brightcove.com/107767373999/107767373999_111735357001_Avatar-MakingAScene-Featurette.mp4?pubId=107767373999&videoId=38467382999",
"size": 129836869,
"height": 360,
"duration": 595567,
"container": "MP4",
"codec": "H264",
"asset_id": "111735357001"
},
{
"avg_bitrate": 1249000,
"width": 640,
"duration": 595567,
"size": 92994065,
"stream_name": "mp4:107767373999/107767373999_111735369001_Avatar-MakingAScene-Featurette.mp4?__nn__=1497926354001&slist=107767373999/&auth=daEciavcicRbhbtdSaBdBdVbXd0aUdTcMaX-bvRrSa-hca-slyCzrux_zJAq_HFCB_EvE&aifp=bcosuds",
"codec": "H264",
"asset_id": "111735369001",
"container": "MP4",
"height": 360,
"app_name": "rtmp://cp150446.edgefcs.net/ondemand"
},
{
"avg_bitrate": 1249000,
"width": 640,
"src": "https://uds.ak.o.brightcove.com/107767373999/107767373999_111735369001_Avatar-MakingAScene-Featurette.mp4?pubId=107767373999&videoId=38467382999",
"size": 92994065,
"height": 360,
"duration": 595567,
"container": "MP4",
"codec": "H264",
"asset_id": "111735369001"
}
],
"name": "Avatar_MakingAScene_Featurette",
"reference_id": "AvatarMakingShort",
"long_description": null,
"duration": 595560,
"published_at": "2010-07-12T22:37:34.760Z",
"text_tracks": [],
"updated_at": "2010-07-12T22:54:29.666Z",
"thumbnail": "https://brightcove04.o.brightcove.com/107767373999/107767373999_111728862001_th-111727994001.jpg?pubId=107767373999&videoId=38467382999",
"poster": "https://brightcove04.o.brightcove.com/107767373999/107767373999_111728861001_vs-111727994001.jpg?pubId=107767373999&videoId=38467382999",
"link": {
"text": "Full Dvd at Amazon",
"url": "https://www.amazon.com/Avatar-Sam-Worthington/dp/B002VPE1AW"
},
"id": "38467382999",
"ad_keys": null,
"thumbnail_sources": [
{
"src": "https://brightcove04.o.brightcove.com/107767373999/107767373999_111728862001_th-111727994001.jpg?pubId=107767373999&videoId=38467382999"
}
],
"created_at": "2010-07-12T22:37:34.760Z"
}
],
}
字幕
隱藏式輔助字幕會為想要存取影片的個人提供其他相關資訊。聾人和聽障人士必須使用字幕,才能存取影片的音訊部分。如果您不熟悉字幕,請參閱概述:為視頻添加字幕文檔。
外部WebVTT
外部 WebVTT 字幕是與視訊分開的文字檔案。您可以將字幕檔案與視訊產生關聯,如下所示:
範例回應
以下是來自Playback API的示例響應,其中已使用Media模塊將WebVTT字幕文件添加到視頻中。請注意,文本軌道src
屬性指向外部字幕文件。
{
"text_tracks": [
{
"mime_type": null,
"account_id": "20318290001",
"default": true,
"sources": [
{
"src": "https://static.3playmedia.com/p/files/2240988/threeplay_transcripts/6418302.vtt?project_id=10127&format_id=51&refresh=1515241856"
}
],
"src": "https://static.3playmedia.com/p/files/2240988/threeplay_transcripts/6418302.vtt?project_id=10127&format_id=51&refresh=1515241856",
"asset_id": null,
"label": "English",
"id": "13d66def-d004-4e75-b160-4ac693eff7d7",
"kind": "captions",
"srclang": "en"
}
],
}
資訊清單內網路
資訊清單內的 WebVTT 字幕會隨影片內嵌。可以在第一次攝取視頻時或攝取視頻後完成。您可以按以下方式創建清單內字幕:
範例回應
以下是來自Playback API的示例響應,其中已使用“動態”將WebVTT字幕文件添加到視頻中 提取API。請注意,文本軌道src
屬性指向內部 Brightcove 文件。
{
"text_tracks": [
{
"mime_type": "text/webvtt",
"account_id": "1752604059001",
"default": false,
"sources": [
{
"src": "https://bcboltbde696aa-a.akamaihd.net/media/v1/text/vtt/clear/1752604059001/3585c49a-5a95-4783-8625-e3af727d094a/92cb36a7-c836-4506-a87f-f649316c0cdf/text.vtt?akamai_token=exp=1518032480~acl=/media/v1/text/vtt/clear/1752604059001/3585c49a-5a95-4783-8625-e3af727d094a/92cb36a7-c836-4506-a87f-f649316c0cdf/text.vtt*~hmac=5aa9f206a8e970efb4cab95278e2e9b16a29b3ccf82951a91245352d9149b173"
},
{
"src": "https://bcboltbde696aa-a.akamaihd.net/media/v1/text/vtt/clear/1752604059001/3585c49a-5a95-4783-8625-e3af727d094a/92cb36a7-c836-4506-a87f-f649316c0cdf/text.vtt?akamai_token=exp=1518032480~acl=/media/v1/text/vtt/clear/1752604059001/3585c49a-5a95-4783-8625-e3af727d094a/92cb36a7-c836-4506-a87f-f649316c0cdf/text.vtt*~hmac=5aa9f206a8e970efb4cab95278e2e9b16a29b3ccf82951a91245352d9149b173"
}
],
"src": "https://bcboltbde696aa-a.akamaihd.net/media/v1/text/vtt/clear/1752604059001/3585c49a-5a95-4783-8625-e3af727d094a/92cb36a7-c836-4506-a87f-f649316c0cdf/text.vtt?akamai_token=exp=1518032480~acl=/media/v1/text/vtt/clear/1752604059001/3585c49a-5a95-4783-8625-e3af727d094a/92cb36a7-c836-4506-a87f-f649316c0cdf/text.vtt*~hmac=5aa9f206a8e970efb4cab95278e2e9b16a29b3ccf82951a91245352d9149b173",
"asset_id": null,
"label": "EN",
"id": "92cb36a7-c836-4506-a87f-f649316c0cdf",
"kind": "captions",
"in_band_metadata_track_dispatch_type": "",
"srclang": "en"
}
],
}
表現
HLS或DASH視頻文件的清單還包含必要的信息,以包含WebVTT字幕。
HLS
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio-0",NAME="en (Main)",DEFAULT=YES,AUTOSELECT=YES,LANGUAGE="en",URI="https://manifest.prod.boltdns.net/manifest/v1/hls/v4/clear/1752604059001/3585c49a-5a95-4783-8625-e3af727d094a/8b12c808-c5ea-47f3-abfa-c23b023db297/10s/rendition.m3u8?fastly_token=NWE3YjU3ZThfNzAwNTczOWM4MWQ4Mzk2NjFkYjVjYmFhYjQwNzY2MWUzM2MyNDM5ZDA5ZGExYTFkMzRmYzA0MDdhOTlmZWJhMw%3D%3D"
#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subtitles-0",NAME="EN",DEFAULT=YES,AUTOSELECT=YES,LANGUAGE="en",URI="https://manifest.prod.boltdns.net/manifest/v1/hls/v4/clear/1752604059001/3585c49a-5a95-4783-8625-e3af727d094a/92cb36a7-c836-4506-a87f-f649316c0cdf/rendition.m3u8?fastly_token=NWE3YjU3ZThfNDYzOThkZGJiZTU1NTlhOTdkYzA5OTA3M2UzZGRlYTgzMmRkZmUxMGIxYTJkY2Y5ZDQ1ODFiNTEyMmNiZDVhMw%3D%3D"
#EXT-X-STREAM-INF:PROGRAM-ID=0,BANDWIDTH=519200,CODECS="mp4a.40.2,avc1.420015",RESOLUTION=480x270,AUDIO="audio-0",CLOSED-CAPTIONS=NONE,SUBTITLES="subtitles-0"
https://manifest.prod.boltdns.net/manifest/v1/hls/v4/clear/1752604059001/3585c49a-5a95-4783-8625-e3af727d094a/5f7850d9-9a65-4eee-8810-86a1e18e05fb/10s/rendition.m3u8?fastly_token=NWE3YjU3ZThfY2Q5YmE2ODc2OWFiNTgyZjUxMjc1MzRhNmQxMzA0ZmJmY2RlMGU4ZjBiNDExZGRmNjc3YjQ0OGQ5N2RiOTVmMA%3D%3D
破折號
<AdaptationSet mimeType="text/vtt" lang="en">
<Representation bandwidth="256" id="92cb36a7-c836-4506-a87f-f649316c0cdf">
<BaseURL>https://bcboltbde696aa-a.akamaihd.net/media/v1/dash/live/clear/1752604059001/3585c49a-5a95-4783-8625-e3af727d094a/92cb36a7-c836-4506-a87f-f649316c0cdf.vtt?akamai_token=exp=1518032494~acl=/media/v1/dash/live/clear/1752604059001/3585c49a-5a95-4783-8625-e3af727d094a*~hmac=3e2edc412c273f1255f2c18bbbcee7afc6a2edb74573f9295b0f05feda69f0e2</BaseURL>
</Representation>
</AdaptationSet>