"This video is unavailable" 将音乐视频放入 iFrame 时

"This video is unavailable" when putting music videos in iFrame

所以我开发了一个应用程序来获取歌曲的 YouTube 视频。 2 个月前,这成功了。回到我的应用程序,突然收到静态 y 错误 "This video is unavailable".

仔细检查了 Youtube 上的视频是否确实存在并播放,我还检查了上传器是否允许使用 https://www.googleapis.com/youtube/v3/videos?id=l-EdCNjumvI&key=[MYKEY]&part=snippet,contentDetails,status

嵌入

我得到状态响应如下: "status":{ "embeddebable":正确 }

所以我知道我应该能够嵌入那个特定的视频。 有什么建议吗?

我可以将其他非音乐视频放入 iframe 中,不会失败。

作品: <iframe width="560" height="315" src="https://www.youtube.com/embed/PUvWR0HdQmg" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>

无效: <iframe width="560" height="315" src="https://www.youtube.com/embed/l- EdCNjumvI" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen> </iframe>

编辑:似乎音乐视频需要服务器 运行 才能播放。我不知道这是为什么,但我使用了一个简单的 http 服务器 python -m http.server 80 由于某种超出我专业知识的原因,它奏效了

测试你的两段代码后,似乎第二个例子中的空格可能是问题所在。

而不是

<iframe width="560" height="315" src="https://www.youtube.com/embed/l- 
EdCNjumvI" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen> 
</iframe>

考虑使用

<iframe width="560" height="315" src="https://www.youtube.com/embed/l-EdCNjumvI" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen> 
</iframe>

连字符后没有空格。

这可能是因为您的示例中的空格在 src 字符串内,这意味着在您的原始示例中,src 字符串是

src="https://www.youtube.com/embed/l- EdCNjumvI"

而不是

src="https://www.youtube.com/embed/l-EdCNjumvI"