我的 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), "*");
}
从上面的部分来看,如果我删除静音部分,视频将无法播放。如果我发送取消静音而不是静音,视频仍然无法播放。如何让正在播放的视频有声音?
扬帆大鱼
炎炎设计
相关分类