如何在 php 中播放 youtube 视频 link

How to play youtube video link in php

我想在我的 php 页面

上播放 YouTube 视频 link

youtube link 是

https://www.youtube.com/watch?v=VAJK04HOLd0

<object width="420" height="315" data="https://www.youtube.com/watch?v=VAJK04HOLd0">

我正在尝试此代码,但它不起作用

要嵌入 YouTube 视频,您应该使用 iframe。

<iframe id="ytplayer" type="text/html" width="640" height="390" src="http://example.com/?autoplay=1" frameborder="0"/>

您可以加​​载<iframe>中的视频文件。试试这个示例代码,

<iframe width="560" height="315" src="https://www.youtube.com/embed/VAJK04HOLd0" frameborder="0" allowfullscreen></iframe>

看最后一部分url https://www.youtube.com/embed/VAJK04HOLd0,

VAJK04HOLd0

这是 youtube 视频代码。如果你想改变视频改变代码。

它没有连接到 php。 您需要将 &autoplay=1 添加到 youtube 字符串中。