自定义叠加图标播放的amp-ima-video错误 - DOMException:play()只能由用户手势启动

时间:2018-02-23 13:02:36

标签: amp-html

我有这段代码在amp-ima-video元素上实现自定义图标播放

  <div class="video-player">
    <amp-ima-video
      id="myVideo"
      width="1280"
      height="720"
      layout="responsive"
      data-tag="https://pubads.g.doubleclick.net/gampad/ads?sz=640x480&iu=/124319096/external/ad_rule_samples&ciu_szs=300x250&ad_rule=1&impl=s&gdfp_req=1&env=vp&output=vmap&unviewed_position_start=1&cust_params=deployment%3Ddevsite%26sample_ar%3Dpremidpost&cmsid=496&vid=short_onecue&correlator=">
      <source src="https://s0.2mdn.net/4253510/google_ddm_animation_480P.mp4" type="video/mp4">
    </amp-ima-video>
    <div id="myOverlay" class="click-to-play-overlay">
      <h3 class="video-title">Title of the video</h3>
      <div class="play-icon"
           role="button"
           tabindex="0"
           on="tap:myOverlay.hide, myVideo.play">
      </div>
      <amp-img class="poster-image"
               layout="fill"
               src="https://unsplash.it/1080/720?image=666">
      </amp-img>
    </div>
  </div>

在我的移动设备(带有Chrome 64.0.3282.137的Android 7.0.0)上点击/点按自定义图标播放时,我收到此错误:

[imaVideo.js] Uncaught (in promise) DOMException: play() can only be initiated by a user gesture.

只有在叠加出现后立即点击它并且播放器似乎尚未初始化时才会发生。当我在播放器似乎已经初始化时出现几秒钟后点击它时,它可以正常工作。

0 个答案:

没有答案