我正在尝试向 Wistia 托管的视频添加播放/暂停按钮。我大部分时间都在工作,但是当我添加多个视频时,它并不是针对当前视频的。相反,当我单击第二个视频时,会播放第一个视频。
下面是 HTML:
<div class="tqm-video-wrapper">
<div class="tqm-video-overlay">
<a class="tqm-play-btn">
</a>
</div>
<!-- WISTIA IN PLACE VIDEO EMBED CODE -->
<script src="https://fast.wistia.com/embed/medias/j04n260140.jsonp" async></script>
<script src="https://fast.wistia.com/assets/external/E-v1.js" async></script>
<div class="wistia_responsive_padding" style="padding:56.25% 0 0 0;position:relative;">
<div class="wistia_responsive_wrapper" style="height:100%;left:0;position:absolute;top:0;width:100%;">
<div class="wistia_embed wistia_async_j04n260140 videoFoam=true" style="height:100%;width:100%"> </div>
</div>
</div>
<!-- END WISTIA IN PLACE VIDEO EMBED CODE -->
</div>
下面是脚本:
window._wq = window._wq || [];
_wq.push({ id: "_all", onReady: function(wistiaEmbed) {
var wistiaHash = $(".wistia_embed").attr("id", "wistiaGenID_" + wistiaEmbed.hashedId());
var wistiaHashId = wistiaEmbed.hashedId();
// grab Wista API
wistiaEmbed = Wistia.api(wistiaHashId);
// when the video is stopped
wistiaEmbed.bind("end", function() {
$(this).find('.tqm-video-overlay').fadeIn("slow");
});
//when the video is paused
wistiaEmbed.bind("pause", function() {
$('.tqm-video-wrapper').find('.tqm-video-overlay').fadeIn("slow");
});
//when the video time changes
wistiaEmbed.bind("secondchange", function() {
$(this).find('.tqm-video-overlay').fadeOut("slow");
});
// when you click the custom play button
$('.tqm-video-overlay').click(function() {
if ($(this).parent().has(".wistia_embed")) {
wistiaEmbed.play();
$(this).fadeOut("slow");
}
});
}
});
这是一个 jsfiddle 的链接:https ://jsfiddle.net/eilawen/bggu5s1q/7/
有人能指出我正确的方向吗?提前致谢。