问题
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 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."
来源:https://stackoverflow.com/questions/10873063/playing-a-monetized-youtube-song-inside-of-a-google-chrome-extension-do-i-have