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