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


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

要將jwplayer嵌入AMP HTML中,有一個名為amp-jwplayer的組件,該組件顯示雲托管的jwplayer。

所需腳本:將amp-jwplayer組件導入標頭

HTML

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

屬性:



  • data-player-id:在JW播放器的播放器部分中找到的字母數字ID。
  • data-playlist-id /data-media-id:在JW播放器的內容部分中找到的字母數字playlist-ID必須指定為playlist-id或media-id。
  • 自動播放:如果指定,則視頻在加載後立即開始播放。

例:

HTML

<!doctype html> 
<html ⚡> 
  
<head> 
    <meta charset="utf-8"> 
    <title>Google AMP amp-jwplayer</title> 
    <script async src= 
        "https://cdn.ampproject.org/v0.js"> 
    </script> 
      
    <!-- Import the `amp-jwplayer`  
        component in the header.-->
    <script async custom-element="amp-jwplayer" 
src="https://cdn.ampproject.org/v0/amp-jwplayer-0.1.js"> 
    </script> 
  
    <link rel="canonical" href= 
"https://amp.dev/documentation/examples/components/amp-jwplayer/index.html"> 
  
    <meta name="viewport" content= 
"width=device-width,minimum-scale=1,initial-scale=1"> 
  
    <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-jwplayer data-media-id="BZ6tc0gy" 
        data-player-id="uoIbMPm3" 
        layout="responsive" width="16" 
        height="9"> 
    </amp-jwplayer> 
</body> 
  
</html>

輸出:




相關用法


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