试图从没有正确的'allow'属性的帧中调用enumerateDevices

问题描述 投票:2回答:1

问题:

是什么引起以下错误,我该如何解决?

我找到了,但是看不懂日语:

https://bisyokuden.com/archives/433

可能与Webkit有关。

https://github.com/WebKit/webkit/blob/master/LayoutTests/http/tests/media/media-stream/enumerate-devices-iframe-allow-attribute-expected.txt

Safari中的错误,但不是Chrome中的错误:

[Error] Trying to call enumerateDevices from a frame without correct 'allow' attribute.
    (anonymous function) (Anonymous Script 1 (line 1))
    MN (Anonymous Script 2 (line 2:7482))
    (anonymous function) (Anonymous Script 2 (line 2:10663))
    (anonymous function) (Anonymous Script 2 (line 2:6198))
    Wk (Anonymous Script 2 (line 2:5376))
    m (Anonymous Script 2 (line 2:6447))
    ut (Anonymous Script 2 (line 2:4204))
    f (Anonymous Script 2 (line 2:5151))
    (anonymous function) (Anonymous Script 2 (line 2:12020))
    (anonymous function) (Anonymous Script 2 (line 2:11961))
    zf (www-embed-player.js:427)
    (anonymous function) (www-embed-player.js:426:114)
    f (www-embed-player.js:400:114)

[Error] Trying to call enumerateDevices from a frame without correct 'allow' attribute.
    (anonymous function) (Anonymous Script 1 (line 1))
    MN (Anonymous Script 3 (line 1:174))
    (anonymous function) (Anonymous Script 2 (line 2:10663))
    (anonymous function) (Anonymous Script 2 (line 2:6198))
    Wk (Anonymous Script 2 (line 2:5376))
    m (Anonymous Script 2 (line 2:6447))
    ut (Anonymous Script 2 (line 2:4204))
    f (Anonymous Script 2 (line 2:5151))
    (anonymous function) (Anonymous Script 2 (line 2:12020))
    (anonymous function) (Anonymous Script 2 (line 2:11961))
    Qo (base.js:967)
    (anonymous function) (base.js:4605:257)
    k (base.js:950:120)

JavaScript帮助器(YT IframeAPI的包装器)

Helpers = window.Helpers || {};
Helpers.Google = Helpers.Google || {};
Helpers.Google.YT = Helpers.Google.YT || {};

Helpers.Google.YT = {

   Player: class Player {

    constructor(element = 'ytplayer', options = { playerVars: { controls: 1 },
                                                  height: '390',
                                                  width: '640',
                                                  videoId: 'novideoid',
                                                  events: {
                                                  'onReady': onPlayerReady,
                                                  'onStateChange': onPlayerStateChange
                                                }}, StubPlayerInstance = null ) {

      if (StubPlayerInstance == undefined) {
        this.player = new YT.Player(element, options);
      } else {
        this.player = StubPlayerInstance;
      }
    }

    loadVideoById($element) {
      var videoId = $element.data('video-id');
      var x = new String(videoId);
      this.player.loadVideoById(x);
    }

    init(modalId){
      const thatInstance = this;
      $(modalId).on('show.bs.modal', function(e) {
        thatInstance.loadVideoById($(e.relatedTarget));
      });  
      return this.player;    
    }
  }
}

var player;


function onYouTubeIframeAPIReady() {
  player = new Helpers.Google.YT.Player().init('#video-modal');
}

function onPlayerReady(event) {
   $('.open-popup').click(function() {
     event.target.playVideo();
   });
   $('.close-popup').click(function(e) {
     player.stopVideo();
   });
 }

function onPlayerStateChange(event) {
   if(event.data === 0) {           
     $('.close.close-popup').click();
   }
 }
javascript jquery youtube-iframe-api
1个回答
0
投票

我遇到了类似的问题(嵌入式YouTube视频仍然可以在我的页面上运行,但是在控制台中仍然看到错误),并且找到了链接到的资源。那里没有更多...

This post describes类似的问题。没有看到您的HTML,我无法确定它是否会有帮助-但它们落在了一个未封闭的<iframe>标签上作为解决方案。

© www.soinside.com 2019 - 2024. All rights reserved.