我的youtube视频在iframe中完美显示,但是没有声音。下面是我的代码。
if (slideType === "youtube") {
switch (control) {
case "play":
postMessageToPlayer(player, {
"event": "command",
"func": "mute"
});
postMessageToPlayer(player, {
"event": "command",
"func": "playVideo"
});
break;
case "pause":
postMessageToPlayer(player, {
"event": "command",
"func": "pauseVideo"
});
break;
}
}
// POST commands to YouTube API
function postMessageToPlayer(player, command){
if (player == null || command == null) return;
player.contentWindow.postMessage(JSON.stringify(command), "*");
}
如果我删除了静音部分,则从以上部分中无法播放视频。如果我发送取消静音而不是静音,则视频无法播放。我如何播放视频声音?
除非,除非你有allow="autoplay;"
你的iframe
标签,你将无法unmute
视频。添加此属性,其他unMute
功能将起作用。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句