我具有php函数,该函数会生成youtube代码以显示视频,但自动播放无法正常工作

function get_youtube_embed($youtube_video_id = 0, $auto = 0) {
    $embed_code = "";
    if ($auto == 1) {
        $embed_code = '<iframe width="589" height="342" src="http://www.youtube.com/embed/' . $youtube_video_id . '?autoplay=1" frameborder="0" allowfullscreen></iframe>';
    }
    else {
        $embed_code = '<iframe width="589" height="342" src="http://www.youtube.com/embed/' . $youtube_video_id . '" frameborder="0" allowfullscreen></iframe>';
    }
    return $embed_code;
}

谢谢

最佳答案

您的代码没问题,请尝试不使用Javascript手动执行。代码中设置自动播放的方式很可能是错误的。

关于php - youtube自动播放不适用于iframe,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7288581/

10-12 12:31
查看更多