问题描述
我在开发Google Chrome浏览器扩展程序时遇到了巨大的障碍。任何YouTube货币化的歌曲(例如广告)都不会播放。
这里记录:
正如你所看到的,玩家拒绝嵌入视频,因为玩家太小了。所以,我改变了玩家的大小,然后再次尝试:
视频开始播放。我已经在扩展中测试了相同的代码,问题也消失了。
因此,创建如下的虚拟框架:
< iframe
width =640
height =390
src =http://www.youtube .com / embed / dummy?enablejsapi = 1
>< / iframe>
更多调试信息:
http:// localhost:8000 /
是Chrome扩展的根目录。我使用 python -m SimpleHTTPServer
来创建服务器。
I have encountered a huge roadblock in the development of my Google Chrome extension. Any YouTube song which is monetized (e.g. has an advertisement) will not play.
This is documented here:https://developers.google.com/youtube/flash_api_reference_as2#Events
as well as here: https://stackoverflow.com/questions/4852490/some-videos-not-playing-through-youtube-api
Previously, I had been using YouTube's Flash API. This worked great until I attempted to deploy my extension. At that point I encountered huge security issues which locked down the app due to insufficient privileges. As such, I rewrote the player to use the iFrame API instead of the Flash API.
The iFrame API allowed me to deploy successfully without any Flash security concerns, but now I am unable to play any song with an advertisement in it.
Does anyone know of a work around for this?
Edit:
My extension can be downloaded here: http://www.meomixes.com/
The source for the extension can be seen here: http://github.com/MeoMix/YouPod
As an example, this song works perfectly OK for me: http://www.youtube.com/watch?v=QXtPoNfOYSo
This song, however, throws an error upon playing: http://www.youtube.com/watch?v=_dfVAAWbLUY
Note that the second song has been monetized.
First, I initialised the player and loaded the video:
As you can see, the player refused to embed the video, because the player is too small. So, I changed the size of the player, and tried again:
The video started playing. I've tested the same code in an extension, and the problem also disappeared.
So, create the dummy frame as follows:
<iframe
width="640"
height="390"
src="http://www.youtube.com/embed/dummy?enablejsapi=1"
></iframe>
Some more debugging information:
- In the previous screenshots,
http://localhost:8000/
is the root directory of the chrome extension. I usedpython -m SimpleHTTPServer
to create the server. - I intercepted the messages between the frame and the page, and found that error code 150 was thrown. According to the documentation, this "is the same as 101", and "the 101 error code is broadcast when the video requested does not allow playback in the embedded players."
这篇关于在Google Chrome扩展程序中播放获利的YouTube歌曲。我有什么选择吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!