我想用我的#play
自定义按钮播放我的iframe视频。我已将iframe放入bootstrap响应嵌入div中。我在iframe中查看正确的内容吗?
JS:
$(document).ready(function ($) {
$('#play').click(function () { //custom button id
$('iframe').contents().find('#wistia_video').get(0).play();
$('.row.grey, .row.header').hide(); //hides elements over htevideo
});
});
HTML:
<div class="embed-responsive embed-responsive-4by3">
<iframe src="//fast.wistia.net/embed/iframe/b4nym2w6dx" allowtransparency="true"
frameborder="0" scrolling="no" class="wistia_embed" name="wistia_embed"
allowfullscreen mozallowfullscreen webkitallowfullscreen oallowfullscreen
msallowfullscreen width="595" height="253"></iframe>
</div>
iframe动态地输入它的类和ID,所以我不能在这里发布它。
答案 0 :(得分:1)
是的,这是一个Cross Domain问题。您最好使用Wistia API
我为你做了JSFiddle。
HTML
<script src="//fast.wistia.net/static/iframe-api-v1.js"></script>
<div class="embed-responsive embed-responsive-4by3">
<iframe id="my_iframe" src="//fast.wistia.net/embed/iframe/b4nym2w6dx" allowtransparency="true" frameborder="0" scrolling="no" class="wistia_embed" name="wistia_embed" allowfullscreen mozallowfullscreen webkitallowfullscreen oallowfullscreen msallowfullscreen width="595" height="253"></iframe>
</div>
<div id="play">Play</div>
JS:
$(document).ready(function ($) {
wistiaEmbed = document.getElementById("my_iframe").wistiaApi;
$('#play').click(function () { //custom button id
wistiaEmbed.play();
$('.row.grey, .row.header').hide();
});
});