外掛程式登錄

在本主題中,您將了解如何使用外掛程式註冊表來追蹤和管理您的 Brightcove 播放程式正在使用的外掛程式。

什麼是插件註冊表?

插件註冊表是用於存儲有關 Brightcove 插件信息的播放器管理 API 的一部分。登錄可作為每個儲存外掛程式的所有版本,以及與每個外掛程式相關聯的指令碼和樣式表的參考。玩家配置利用插件註冊表,顯示當前的插件版本,並允許您指定插件版本。

優點

Prightcove 播放器用戶插件註冊表的優點是三倍:

  • 您可以看到您的播放器正在使用哪個版本的插件,以及與該特定插件版本相關的特定 JavaScript 和 CSS 文件。
  • 您可以將外掛程式設定為在與您的播放程式版本相容的新版本發行時自動更新。
  • 如果您因某種原因選擇將某個玩家保留在特定的播放程式版本中,您的外掛程式會在該玩家鎖定時保持相同的特定版本。您不必擔心外掛程式升級到與您的播放程式版本不相容的版本。

目前合格外掛程式

下表顯示了與插件註冊表工作的 Brightcove 提供的插件。外掛程式登錄 ID 將與播放程式設定搭配播放程式管理 API 搭配使用。本文件中會顯示許多範例。

外掛程式名稱 外掛程式登錄 ID
Adobe 分析播放器 @brightcove/視頻-BC-AA
鉻接收器 @brightcove /視訊js-鉻-接收器
自訂螢幕終止畫面 @brightcove /影片自訂的結束畫面
DRM @brightcove /視訊/影片DRM
谷歌分析播放器 @brightcove/視頻-BC-ga
IM3 廣告 @brightcove /視訊js-ima3
覆疊 @brightcove /影片覆蓋
子母畫面 @brightcove /視訊點子
播放清單 UI @brightcove /視訊ojs-BC-播放清單-使用者介面
品質選擇功能表 @brightcove /視訊-品質-選單
社交 @brightcove /視訊-社交
智囊團 @brightcove /視頻
茶點播放器外掛程式 @brightcove /視訊ojs-BC-茶

指定外掛程式的使用

要指定插件的使用,在您的播放器創建中,您只需提供所需插件的註冊表 ID。您必須指定版本號碼,可能是將自動更新的主要版本 (例如 2.x ) 或不會自動更新的次要版本 (例如 2.0.10 )。關於設定版本的詳細資訊會顯示在本文件稍後。您也可以提options供插件,如果有的話。

    curl \
      --header "Content-Type: application/json" \
      --user $EMAIL \
      --request POST \
      --data '{
        "name": "Plugin Registry Test Player",
        "configuration": {
          "video_cloud": {
            "video": "4093372393001"
          },
          "plugins": [
           {
              "registry_id": "@brightcove/videojs-custom-endscreen",
              "version": "2.x",
              "options": { "content": "<strong>Content</strong> for <em>custom</em> end screen" }
           }
          ]
        }
      }' \
      https://players.api.brightcove.com/v2/accounts/{account_id}/players
          

玩家管理 API 會傳回所建立播放程式的相關資訊。您可以使用返回的 URL 值,將 index.html 更改為配置 .json ,並瀏覽該 URL 以查看已發布播放器的配置。

    {
      "id": "rkGD9W22Ob",
      "url": "https://players.brightcove.net/1507807800001/rkGD9W22Ob_default/index.html",
      "embed_code": "<iframe src='//players.brightcove.net/1507807800001/rkGD9W22Ob_default/index.html' allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe>",
      "embed_in_page": "https://players.brightcove.net/1507807800001/rkGD9W22Ob_default/in_page.embed",
      "preview_url": "https://preview-players.brightcove.net/v2/accounts/1507807800001/players/rkGD9W22Ob/preview/embeds/default/master/index.html",
      "preview_embed_code": "<iframe src='//preview-players.brightcove.net/v2/accounts/1507807800001/players/rkGD9W22Ob/preview/embeds/default/master/index.html' allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe>"
    }

在發布播放器的配置中,您可以看到插件上的信息。請注意,系統會顯示特定版本的外掛程式,以及對應的 JavaScript 和 CSS 檔案的值。

    {
      "account_id": "1507807800001",
      "compatibility": true,
      "embed_id": "default",
      "player": {
        "template": {
          "name": "single-video-template",
          "version": "6.7.0"
        }
      },
      "player_id": "SyITgzdjb",
      "player_name": "Plugin Registry Test Player",
      "plugins": [{
        "injected_version": "2.0.10",
        "name": "customEndscreen",
        "registry_id": "@brightcove/videojs-custom-endscreen",
        "version": "2.x"
      }],
      "scripts": [
        "//players.brightcove.net/videojs-custom-endscreen/2.0.10/videojs-custom-endscreen.min.js"
      ],
      "stylesheets": [
        "//players.brightcove.net/videojs-custom-endscreen/2.0.10/videojs-custom-endscreen.css"
      ],
      "updated_at": "2017-09-26T17:39:10.080Z",
      "video_cloud": {
        "policy_key": "BCpkADawqM3hOj9I_wRb6jx7SLoklIm8eiW-MH1C0CO5xnf8ndABL7WJQOVdWIusPlnfKUD5EZvjHyJOQGeCFndODaM7CRz4h4GxUTLN3OmO7dTcLnxS3cYrXOZx4eaqaSbVFDx1yFTvWX7m",
        "video": "4093372393001"
      }
    }

指定特定的主要版本

您可以設定播放程式,使用與您所使用的播放程式相容的特定主要版本的外掛程式的最新版本。當您執行這項操作時,外掛程式的次要版本會自動更新為最新的次要版本。

例如,如果您希望播放器包含外掛程式主要版本 2 的自訂終端螢幕外掛程式的最新相容版本,您可以使用下列項目:

    curl \
      --header "Content-Type: application/json" \
      --user $EMAIL \
      --request POST \
      --data '{
        "name": "Plugin Registry Test Player",
        "configuration": {
          "video_cloud": {
            "video": "4093372393001"
          },
          "plugins": [
            {
              "registry_id": "@brightcove/videojs-custom-endscreen",
              "version": "2.x"
            }
          ]
        }
      }' \
      https://players.api.brightcove.com/v2/accounts/{account_id}/players

產生的組態會出現類似下列內容:

    "plugins": [{
      "injected_version": "2.0.10",
      "name": "customEndscreen",
      "registry_id": "@brightcove/videojs-custom-endscreen",
      "version": "2.x"
    }],
    "scripts": [
      "//players.brightcove.net/videojs-custom-endscreen/2.0.10/videojs-custom-endscreen.min.js"
    ],
    "stylesheets": [
      "//players.brightcove.net/videojs-custom-endscreen/2.0.10/videojs-custom-endscreen.css"
    ],

指定特定版本

您可以指定要使用的外掛程式的特定版本。如果您這樣做,插件在任何情況下都不會自動更新,因此如果需要,您將不得不手動更新。

要鎖定一個版本的插件,只需在創建播放器時指定版本:

    curl \
      --header "Content-Type: application/json" \
      --user $EMAIL \
      --request POST \
      --data '{
        "name": "Plugin Registry Test Player",
        "configuration": {
          "video_cloud": {
            "video": "4093372393001"
          },
          "plugins": [
            {
              "registry_id": "@brightcove/videojs-overlay",
              "version": "1.0.2"
            }
          ]
        }
      }' \
      https://players.api.brightcove.com/v2/accounts/{account_id}/players
          

播放器配置將反映特定版本,以及在 JavaScript 和 CSS 文件中:

    "plugins": [{
      "name": "overlay",
      "registry_id": "@brightcove/videojs-overlay",
      "version": "1.0.2"
    }],
    "scripts": [
      "//players.brightcove.net/videojs-overlay/1.0.2/videojs-overlay.min.js"
    ],
    "stylesheets": [
      "//players.brightcove.net/videojs-overlay/1.0.2/videojs-overlay.css"
    ],
          

不相容的指派

如果您嘗試將不相容的外掛程式指派給玩家,或變更播放器的版本,以致先前指定的外掛程式不再相容,則會發生錯誤。錯誤在這裡詳細說明。

指派外掛程式給不相容的播放器

如果在任何時候,無論是在播放器創建或更新中,您嘗試指定與播放器版本不兼容的插件版本,則會出現錯誤。例如,嘗試將不兼容的舊插件分配給新播放器時,以下是 API 的響應:

    {
      "message": "There are no versions of the plugin that match the specified major version. The major version specified was 1.x for plugin @brightcove/videojs-bc-playlist-ui",
      "error_code": "PLAYER_MANAGEMENT_ERROR",
    }
          

更改播放器版本,以便與插件不兼容

如果您嘗試變更現有播放程式的版本,而該播放程式已經擁有與新指定的播放程式版本不相容的外掛程式,您將會收到類似下列內容的錯誤訊息:

    {
      "error_code":"APPLICATION_ERROR",
      "message":"plugin \"@brightcove/videojs-ima3\" is not compatible with template 5.28.1"
    }
    

工作室配置的插件

如果一個插件是通過 Studio 加載,該插件將反映在插件註冊表中的新功能:

    {
      "account_id": "1507807800001",
      "compatibility": true,
      "embed_id": "default",
      "player": {
        "template": {
          "name": "single-video-template",
          "version": "6.7.0"
        }
      },
      "player_id": "SJajDfuiW",
      "player_name": "Plugin Registry Studio Configuration",
      "plugins": [{
        "injected_version": "2.0.10",
        "name": "customEndscreen",
        "options": {
          "content": "<h3>This is the endscreen content</h3>"
        },
        "registry_id": "@brightcove/videojs-custom-endscreen",
        "version": "2.x"
      }],
      "scripts": [
        "//players.brightcove.net/videojs-custom-endscreen/2.0.10/videojs-custom-endscreen.min.js"
      ],
      "stylesheets": [
        "//players.brightcove.net/videojs-custom-endscreen/2.0.10/videojs-custom-endscreen.css"
      ],
      "updated_at": "2017-09-26T18:09:31.940Z",
      "video_cloud": {
        "policy_key": "BCpkADawqM3YPJvvfxBgJNEGrPjTPoOw0LyCbiTPnDGtAVExTzXeAW3hcRtPpS8tNeSiA9MosLG076eMXWO8E2Lxv-V7mq1oTIgqK7Xf0HBP_TEm1i-e5zRN_VIW_SjFagYpRxuoM8btiEoD",
        "video": null
      }
    }
          

正如你可以在播放器配置中看到的,Studio 中加載的插件將使用主要版本行為進行更新,也就是說,次要版本更新將被自動應用。

更新登錄資訊

您可以使用標準程序更新玩家的外掛程式登錄資訊。例如,下面的 curl 語句使用 HTTP 方PATCH 法將插件從特定版本更改為主要版本更新行為:

    curl \
      --header "Content-Type: application/json" \
      --user $EMAIL \
      --request PATCH \
      --data '{
        "plugins": [{
          "registry_id": "@brightcove/videojs-custom-endscreen",
          "version": "2.x"
        }]
      }' \
      https://players.api.brightcove.com/v2/accounts/{account_id}/players/{player_id}/configuration
          

請記住,您必須在進行變更後發佈播放器。

外掛程式登錄 API

Player 管理 API 新增了兩個新端點,可從登錄機中擷取外掛程式資訊,這些資訊可讓您:

  • 檢索註冊表中的所有插件。
  • 擷取特定外掛程式的資訊。

取得所有外掛程式

使用以下內容來擷取登錄中目前外掛程式的相關資訊。

    curl \
      --header "Content-Type: application/json" \
      --user $EMAIL \
      --request GET \
      https://players.api.brightcove.com/v2/plugins
          

傳回的資訊會顯示類似下列內容:

    [{
      "documentation": "https://support.brightcove.com/configuring-adobe-analytics-event-tracking",
      "description": "Adobe Analytics Player Plugin",
      "id": "@brightcove/videojs-bc-aa",
      "name": "bcAa",
      "current_version": "1.x"
    }, {
      "documentation": "https://support.brightcove.com/configuring-google-analytics-event-tracking",
      "description": "Google Analytics Player Plugin",
      "id": "@brightcove/videojs-bc-ga",
      "name": "bcGa",
      "current_version": "1.x"
    }, {
      "documentation": "https://support.brightcove.com/google-tag-manager-plugin-brightcove-player",
      "description": "Google Tag Manager Player Plugin",
      "id": "@brightcove/videojs-bc-gtm",
      "name": "bcGtm",
      "current_version": "1.x"
    }, {
      "documentation": "https://support.brightcove.com/playlist-ui-plugin",
      "description": "Brightcove customizations to videojs-playlist-ui",
      "id": "@brightcove/videojs-bc-playlist-ui",
      "name": "bcPlaylistUi",
      "current_version": "3.x"
    }, {
      "documentation": "https://support.brightcove.com/tealium-plugin-brightcove-player",
      "description": "Tealium Player Plugin",
      "id": "@brightcove/videojs-bc-tealium",
      "name": "bcTealium",
      "current_version": "1.x"
    }, {
      "documentation": "https://support.brightcove.com/beta-chromecast-plugin-brightcove-player",
      "description": "A Chromecast Receiver plugin for the Brightcove Player",
      "id": "@brightcove/videojs-chromecast-receiver",
      "name": "chromecastReceiver",
      "current_version": "1.x"
    }, {
      "documentation": "https://support.brightcove.com/custom-endscreen-plugin",
      "description": "Custom endscreens for video.js.",
      "id": "@brightcove/videojs-custom-endscreen",
      "name": "customEndscreen",
      "current_version": "2.x"
    }, {
      "documentation": "https://support.brightcove.com/configuring-brightcove-player-drm",
      "description": "Cross-browser support for MPEG-DASH w/ DRM using dash.js and silverlight and HLS Fairplay DRM",
      "id": "@brightcove/videojs-drm",
      "name": "eme",
      "current_version": "5.x"
    }, {
      "documentation": "https://support.brightcove.com/advertising-ima3-plugin",
      "description": "Google Interactive Media Ads (IMA) v3 support for video.js",
      "id": "@brightcove/videojs-ima3",
      "name": "ima3",
      "current_version": "3.x"
    }, {
      "documentation": "https://support.brightcove.com/display-overlay-plugin",
      "description": "Overlay for video.js.",
      "id": "@brightcove/videojs-overlay",
      "name": "overlay",
      "current_version": "2.x"
    }, {
      "documentation": "https://support.brightcove.com/picture-picture-plugin-aka-floating-or-pinned",
      "description": "A plugin for enabling a Picture-In-Picture mode for the Brightcove Player",
      "id": "@brightcove/videojs-pip",
      "name": "pip",
      "current_version": "1.x"
    }, {
      "documentation": "https://support.brightcove.com/manual-rendition-selection-plugin",
      "description": "Quality Selection Menu UI",
      "id": "@brightcove/videojs-quality-menu",
      "name": "qualityMenu",
      "current_version": "1.x"
    }, {
      "documentation": "https://support.brightcove.com/social-media-plugin",
      "description": "Social sharing integrations for video.js.",
      "id": "@brightcove/videojs-social",
      "name": "social",
      "current_version": "3.x"
    }, {
      "documentation": "https://support.brightcove.com/advertising-ssai-plugin",
      "description": "A plugin for the Brightcove Player implementing playback of SSAI streams.",
      "id": "@brightcove/videojs-ssai",
      "name": "ssai",
      "current_version": "1.x"
    }]
          

取得特定外掛程式資訊

使用以下內容來擷取特定外掛程式的相關資訊。請注意,外掛程式名稱必須是 URL 編碼,所以不要@brightcove/videojs-ima3 使用%40brightcove%2fvideojs-ima3

    curl \
      --header "Content-Type: application/json" \
      --user $EMAIL \
      --request GET \
      https://players.api.brightcove.com/v2/plugins/%40brightcove%2fvideojs-ima3
          

傳回的資訊會顯示類似下列內容:

    {
      "versions": [{
        "scripts": ["//players.brightcove.net/videojs-ima3/3/videojs.ima3.min.js"],
        "stylesheets": ["//players.brightcove.net/videojs-ima3/3/videojs.ima3.min.css"],
        "version_number": "3.x",
        "minimum_template_version": "6.0.0"
      }, {
        "minimum_template_version": "5.0.0",
        "version_number": "2.x",
        "stylesheets": ["//players.brightcove.net/videojs-ima3/2/videojs.ima3.min.css"],
        "scripts": ["//players.brightcove.net/videojs-ima3/2/videojs.ima3.min.js"]
      }, {
        "minimum_template_version": "1.14.0",
        "version_number": "1.x",
        "stylesheets": ["//players.brightcove.net/videojs-ima3/1/videojs.ima3.min.css"],
        "scripts": ["//players.brightcove.net/videojs-ima3/1/videojs.ima3.min.js"]
      }],
      "documentation": "https://support.brightcove.com/advertising-ima3-plugin",
      "description": "Google Interactive Media Ads (IMA) v3 support for video.js",
      "id": "@brightcove/videojs-ima3",
      "name": "ima3",
      "current_version": "3.x"
    }

雖然沒有顯示在這個響應中,你也可以看到一個before_template-version 屬性和相應的值。這將出現在較舊的插件,並設置與該插件版本兼容的最新播放器模板版本。minimum_template_version 和一起before_template-version 工作來設置與插件兼容的播放器模板版本的範圍。