“This video is unavailable” when putting music videos in iFrame

こ雲淡風輕ζ 提交于 2019-12-08 12:52:23

问题


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".

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

I got the status response as follows: "status" : { "embeddebable" : true }

So I know I should be able to embed that particular video. Any advice?

I am able to put other non-music videos into the iframe without fail.

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

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

Edit: 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


回答1:


After testing your two pieces of code, it seems that the spaces in the second example may be the problem.

Instead of

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

consider using

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

where there are no spaces after the hyphen.

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"

rather than

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



来源:https://stackoverflow.com/questions/51316379/this-video-is-unavailable-when-putting-music-videos-in-iframe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!