當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


Google AMP amp-brightcove用法及代碼示例


Brightcove Video Cloud是用於托管視頻的在線平台。 amp-brightcove是一個放大器組件,用於嵌入Brightcove視頻表演播放器或Brightcove視頻雲。

所需腳本:在標題中導入Brightcove組件

HTML

<script async custom-element="amp-brightcove" src= 
"https://cdn.ampproject.org/v0/amp-brightcove-0.1.js"> 
</script>

屬性:



  1. data-account:Brightcove Video Cloud帳戶ID。
  2. data-video-id:Brightcove視頻雲ID。
  3. data-player-id:Brightcove播放器ID。這是一個全局唯一標識符(GUID)。
  4. data-playlist-id:Brightcove Video Cloud播放列表ID。如果同時指定了播放列表和視頻,則播放列表優先於視頻。
  5. autoplay:如果指定了此屬性,則視頻將自動開始。
  6. dock:如果指定了此屬性,並且視頻正在手動播放,則視頻將被最小化。使用此屬性需要amp-video-docking擴展名。

如下所示嵌入了Brightcove視頻,需要data-account,data-video-id,data-player-id。

HTML

<amp-brightcove data-account="906043040001"
    data-video-id="1401169490001"
    data-player-id= 
        "180a5658-8be8-4f33-8eba-d562ab41b40c"
        layout="responsive" width="480"
        height="270"> 
</amp-brightcove>

有關Brightcove播放器配置的說明,您可以查看以下Brightcove的支持文檔。 https://amp.dev/documentation/components/amp-brightcove/?format=websites

例:

HTML

<!doctype html> 
<html amp> 
  
<head> 
    <meta charset="utf-8"> 
    <title>Google AMP amp-brightcove</title> 
    <script async src= 
        "https://cdn.ampproject.org/v0.js"> 
    </script> 
      
    <!-- Import the Brightcove component  
         in the header. -->
    <script async custom-element= 
        "amp-brightcove" src= 
"https://cdn.ampproject.org/v0/amp-brightcove-0.1.js"> 
    </script> 
  
    <meta name="viewport" content= 
"width=device-width,minimum-scale=1,initial-scale=1"> 
  
    <link rel="canonical" href= 
"https://amp.dev/documentation/examples/components/amp-brightcove/index.html"> 
  
    <style amp-boilerplate> 
        body { 
            -webkit-animation:-amp-start 8s  
                steps(1, end) 0s 1 normal both; 
  
            -moz-animation:-amp-start 8s  
                steps(1, end) 0s 1 normal both; 
  
            -ms-animation:-amp-start 8s  
                steps(1, end) 0s 1 normal both; 
  
            animation:-amp-start 8s  
                steps(1, end) 0s 1 normal both 
        } 
  
        @-webkit-keyframes -amp-start { 
            from { 
                visibility:hidden 
            } 
  
            to { 
                visibility:visible 
            } 
        } 
  
        @-moz-keyframes -amp-start { 
            from { 
                visibility:hidden 
            } 
  
            to { 
                visibility:visible 
            } 
        } 
  
        @-ms-keyframes -amp-start { 
            from { 
                visibility:hidden 
            } 
  
            to { 
                visibility:visible 
            } 
        } 
  
        @-o-keyframes -amp-start { 
            from { 
                visibility:hidden 
            } 
  
            to { 
                visibility:visible 
            } 
        } 
  
        @keyframes -amp-start { 
            from { 
                visibility:hidden 
            } 
  
            to { 
                visibility:visible 
            } 
        } 
    </style> 
    <noscript> 
        <style amp-boilerplate> 
            body { 
                -webkit-animation:none; 
                -moz-animation:none; 
                -ms-animation:none; 
                animation:none 
            } 
        </style> 
    </noscript> 
</head> 
  
<body> 
  
    <amp-brightcove data-account="906043040001" 
        data-video-id="1401169490001"
        data-player-id= 
            "180a5658-8be8-4f33-8eba-d562ab41b40c" 
        layout="responsive" width="480" 
        height="270"> 
    </amp-brightcove> 
</body> 
  
</html>

輸出:




相關用法


注:本文由純淨天空篩選整理自somsagar2019大神的英文原創作品 Google AMP amp-brightcove。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。