我尝试从 3 天开始在 google chrome 中使用“声音取消静音”自动播放 YouTube 嵌入视频,但它不起作用。虽然相同的视频和相同的代码可以在 mozilla firefox 中运行。我尝试过不同的代码,但到目前为止还没有成功。
这是代码。
<head>
<style>
body{
margin-left: 0px;
}
</style>
</head>
<script src="js/jquery-3.1.1.min.js"></script>
<div id="YouTubeVideoPlayer"></div>
<script async src="https://www.youtube.com/iframe_api"></script>
<script>
function onYouTubeIframeAPIReady() {
var player;
player = new YT.Player('YouTubeVideoPlayer', {
videoId: 'M7lc1UVf-VE', // YouTube Video ID
width: 560, // Player width (in px)
height: 316,
start:0, // Player height (in px)
playerVars: {
autoplay: 1, // Auto-play the video on load
controls: 1, // Show pause/play buttons in player
showinfo: 0, // Hide the video title
modestbranding: 1, // Hide the Youtube Logo
loop: 1, // Run the video in a loop
fs: 0, // Hide the full screen button
cc_load_policy: 0, // Hide closed captions
iv_load_policy: 3, // Hide the Video Annotations
autohide: 0 // Hide video controls when playing
},
events: {
onReady: function(e) {
e.target.setVolume(40);
}
}
});
}
$("body").animate({ margin: "400px 0px 0px 0px" }, 18000 );
</script>
您需要将静音设置为 0,并且在视频开始后,您需要在 0:01 秒处触发,将音量调回 40。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)