When I try to load certain videos (such as popular songs), the API returns the error code 150 (video requested does not allow playback in the embedded players). However, it works if I load the video in an iframe or embed tag.
This works:
<iframe width="560" height="315" src="http://www.youtube.com/embed/j5-yKhDd64s" frameborder="0" allowfullscreen></iframe>
This also works:
<object width="560" height="315"><param name="movie" value="http://www.youtube.com/v/j5-yKhDd64s?version=3&hl=en_GB"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/j5-yKhDd64s?version=3&hl=en_GB" type="application/x-shockwave-flash" width="560" height="315" allowscriptaccess="always" allowfullscreen="true"></embed></object>
This alerts the 150 error:
var defaultVideo = 'j5-yKhDd64s';
var player;
function onYouTubePlayerAPIReady() {
player = new YT.Player('player-wrap', {
height: '390',
width: '640',
videoId: defaultVideo,
events: {
'onError': onPlayerError
}
});
}
function onPlayerError(event) {
alert('Error: '+event.data);
player.stopVideo();
player.loadVideoById('');
}
Why is this?
Here's the reference for the API: http://code.google.com/apis/youtube/js_api_reference.html#Events
-
possible duplicate of youtube 150 error in Air appRay– Ray2011年11月11日 10:51:22 +00:00Commented Nov 11, 2011 at 10:51
3 Answers 3
This error code dates back from 2009+, If you get error code 150, the video won't work on any browser or any player.
Error code 150: The video can only be player with advertisements at youtube.
Comments
Look at https://developers.google.com/youtube/js_api_reference#onError
101 – The owner of the requested video does not allow it to be played in embedded players.
150 – This error is the same as 101. It's just a 101 error in disguise!
Comments
I've had a similar issue when embedding some protected videos using the Iframe API. The videos were playing on Chrome, but resulting in a error 150 when browsing with Firefox and Safari.
The only workaround I found was to switch back to the Javascript API that relies on a Flash embed. For some reason, all video embeds now work on every browser, I have not seen any error 150 since then.