是否可以在没有嵌入 url 的情况下实现 YouTube 视频?

Is it possible to implement a youtube video without the embed url?

我知道通常必须实施 /embed/ URL 以在页面上放置视频,即: <iframe id="ytplayer" type="text/html" width="640" height="390" src="http://www.youtube.com/embed/M7lc1UVf-VE?autoplay=1&origin=http://example.com" frameborder="0"/>

我今天的问题是,没有 /embed/ 是否可以实现它?

https://youtu.be/M7lc1UVf-VE

原因在于我开发的一个人不小心使用了整个 youtube 链接而不是嵌入的系统,我正在考虑使用 PHP 制作一个解析脚本,但我确信有一个更简单的方法方式。

我找不到解决方案,所以我只是使用了上面提到的 PHP 等价物。

$raw = "https://youtu.be/M7lc1UVf-VE";
$url = str_replace($raw, "youtu.be/", "youtube.com/embed/");