Playing a monetized YouTube song inside of a Google Chrome Extension. Do I have any options?

爱⌒轻易说出口 提交于 2019-12-11 00:59:57

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/10873063/playing-a-monetized-youtube-song-inside-of-a-google-chrome-extension-do-i-have

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