当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。