嵌入式YouTube视频应该在页面加载时自动播放并且最初加载静音。然后,用户可以根据需要使用控件取消静音。
iOS使用本机覆盖YouTube控件,静音/取消静音按钮永久消失。如何在IOS中显示静音/取消静音按钮?
<style type="text/css">
.embed-container {
position: relative;
padding-bottom: 56.25%;
height: 0;
overflow: hidden;
max-width: 100%;
}
.embed-container iframe,
.embed-container object,
.embed-container embed {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
</style>
<div class="embed-container">
<iframe allowfullscreen="" frameborder="0" src="https://www.youtube.com/embed/cvRzPbeVp9I?rel=0&controls=1&showinfo=0&mute=1&autoplay=1&t=17s"></iframe>
</div>
答案 0 :(得分:0)
在查阅iOS文档后,立即回答是无法覆盖原生iOS HTML5视频控件。 iOS不支持&#34; MUTE&#34;控制,没有办法改变这一点。
但是,在这种特殊情况下,我得到了以下解决方法。
<!--Responsify CSS Block -->
<style type="text/css">
.embed-container {
position: relative;
padding-bottom: 56.25%;
height: 0;
overflow: hidden;
max-width: 100%;
}
.embed-container iframe, .embed-container object,
.embed-container embed {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
}
<!--Media queries to control YouTube video embed containers by screen size -->
.dektop-dayday2-visible {
display: none;
}
.mobile-dayday2-visible {
display: none;
}
@media (max-width: 1024px) {
.dektop-dayday2-visible {
display: none;
}
.mobile-dayday2-visible {
display: block;
}
@media (min-width: 1025px) {
.dektop-dayday2-visible {
display: block;
}
.mobile-dayday2-visible {
display: none;
}
</style>
&#13;
<div class="embed-container dektop-dayday2-visible"><iframe allowfullscreen="" frameborder="0" src="https://www.youtube.com/embed/cvRzPbeVp9I?rel=0&controls=1&showinfo=0&mute=1&autoplay=1"></iframe></div>
<div class="embed-container mobile-dayday2-visible"><iframe allowfullscreen="" frameborder="0" src="https://www.youtube.com/embed/cvRzPbeVp9I?rel=0&controls=1&showinfo=0&autoplay=0"></iframe></div>
&#13;