gpt4 book ai didi

javascript - 传递的播放器元素不是 Vimeo 嵌入。玩家JS

转载 作者:行者123 更新时间:2023-12-01 04:01:24 26 4
gpt4 key购买 nike

我使用 Vimeo 播放器的 JavaScript API 在用户单击网站上的特定按钮时启动视频。

这是嵌入的代码:

<iframe id="vimeo-player" src="<?php the_sub_field('slide_video'); ?>?title=0&byline=0&portrait=0" width="1880" height="1058" frameborder="0" ></iframe>

这是 JavaScript:

    var iframe = document.querySelector('#vimeo-player');
var player = new Vimeo.Player(iframe);

$('.slide-area__slides__video svg').click(function(){
$(this).hide();
$(this).closest('.item').find('img').hide();
$(this).siblings('iframe').show();
player.play();
});

player.on('ended', function(data) {
$('.slide-area__slides__video svg').show();
$('.slide-area__slides__video iframe').hide();
$('.slider-area__slides .item img').show();
});

它在 Chrome 中完美运行,但在其他所有浏览器中,它只是不断抛出错误:

The player element passed isn’t a Vimeo embed.

有人遇到过这种情况吗?真是令人沮丧。

最佳答案

查看player.js,似乎在以下情况下显示错误:

if (element.nodeName === 'IFRAME' && !isVimeoUrl(element.getAttribute('src') || '') {...}

确保 the_sub_field('slide_video') 输出有效的 Vimeo URL。

关于javascript - 传递的播放器元素不是 Vimeo 嵌入。玩家JS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41965001/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com