1
votes

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&amp;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&amp;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

3
possible duplicate of youtube 150 error in Air app - Ray

3 Answers

1
votes

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.

0
votes

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.

0
votes

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!