我已经尝试了很多指南并阅读了很多关于这个问题的答案,但仍未设法解决这个问题。如何将mytube嵌入式视频静音? 附:我是编码的新手和SOF的新手,请原谅我,如果我做了一些可怕的错误。
<div class="video-bg embed-responsive embed-responsive-16by9">
<iframe class="embed-responsive-item" width="560" height="315"
src="https://www.youtube.com/embed/ArGfDo1xQuM?rel=0&controls=0&showinfo=0&frameborder=0&autoplay=1&loop=1&playlist=eXadofBB7hM" frameborder="0" allowfullscreen></iframe>
</div>
答案 0 :(得分:0)
您必须使用iframe_api
。在 iframe src 属性中,您必须添加enablejsapi=1
,同时 iframe 具有 id 属性,将其与YT.Player
实例连接。然后使用此JavaScript来控制电影播放。
<script src='http://www.youtube.com/iframe_api'></script>
<script>
var player;
function onYouTubeIframeAPIReady() {
player = new YT.Player('playerId', {
events: {
onReady:onPlayerReady
}
}
)
}
function onPlayerReady(event) {
player.mute();
player.setVolume(0);
player.playVideo();
}
</script>
<div class="video-bg embed-responsive embed-responsive-16by9">
<iframe id='playerId' class="embed-responsive-item" width="560" height="315"
src="https://www.youtube.com/embed/ArGfDo1xQuM?rel=0&controls=0&showinfo=0&frameborder=0&autoplay=1&loop=1&playlist=eXadofBB7hM&enablejsapi=1" frameborder="0" allowfullscreen></iframe>
</div>