“此视频不可用"将音乐视频放入 iFrame 时 [英] "This video is unavailable" when putting music videos in iFrame
问题描述
所以我开发了一个应用程序来获取歌曲的 youtube 视频.2 个月前,这确实有效.回到我的应用程序,突然收到静态错误此视频不可用".
So I developed an app that fetches the youtube video for songs. 2 months ago this worked without fail. Came back to my app and suddenly getting the static-y error "This video is unavailable".
仔细检查了 Youtube 上的视频是否确实存在并播放,我还检查了上传者是否允许使用 https://www.googleapis.com/youtube/v3/videos?id=l-EdCNjumvI&key=[MYKEY]&part=snippet,contentDetails,status
Double checked that the video on Youtube is actually there and plays, and I also checked to see if the uploader allows embedding by using https://www.googleapis.com/youtube/v3/videos?id=l-EdCNjumvI&key=[MYKEY]&part=snippet,contentDetails,status
我得到的状态响应如下:地位" : {"embeddebable" : true}
I got the status response as follows: "status" : { "embeddebable" : true }
所以我知道我应该能够嵌入那个特定的视频.有什么建议吗?
So I know I should be able to embed that particular video. Any advice?
我可以毫无问题地将其他非音乐视频放入 iframe.
I am able to put other non-music videos into the iframe without fail.
作品:<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" 允许="自动播放;加密媒体"allowfullscreen></iframe>
似乎音乐视频需要运行服务器才能播放.我不知道这是为什么,但我使用了一个简单的 http 服务器python -m http.server 80
出于某种超出我专业知识范围的原因,它奏效了
it seems music videos need a server to be running in order to play. I don't know why this is, but I started a simple http server using
python -m http.server 80
and for some reason that is above my expertise, that worked
推荐答案
测试你的两段代码后,似乎第二个示例中的空格可能是问题所在.
After testing your two pieces of code, it seems that the spaces in the second example may be the problem.
代替
<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 字符串是
This may be due to the fact that the spaces in your example are WITHIN the src string, meaning that in your original example, the src string was
src="https://www.youtube.com/embed/l- EdCNjumvI"
而不是
src="https://www.youtube.com/embed/l-EdCNjumvI"
这篇关于“此视频不可用"将音乐视频放入 iFrame 时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!