Youtube chromeless player underscore problem

I am using the youtube chromeless player and embeding videos with loadVideoById() method
problem is that videos with an id that contains an underscore or dash dont play although they play in the normal player.

I also tried replacing with a hex value in querystring i.e (%5f) but that did not work

I also tried loadVideoByUrl() method with several urls but still they don’t load.

here is my code

function switchToPlayer(ytid){

var params = { allowScriptAccess: “always”};
var atts = { id: ytid,onmouseover: “this.playVideo()”,onmouseout: “this.pauseVideo()”};
swfobject.embedSWF(“”+ytid, ‘cell’+ytid, “150”, “120”, “8”, “scripts/expressInstall.swf”,null,params,atts);


function onYouTubePlayerReady(playerapiid) {
ytplayer = document.getElementById(playerapiid);

Can you post an ID that you’re having trouble with? I’m looking for a video to test with, but they all have IDs that are totally alphanumeric (4lsCA2eQMog, HfamHCd6dXE, etc).

Here’s some recent ones with underscores and dashes




Thanks, paul_wilkins

Now that we got that squared away, there were two different mistakes I made that prevented the hyphenated one from working:

  1. I needed to decode the playerapiid. When it wouldn’t work, the first thing I did was make sure the onYouTubePlayerReady function was getting the correct id. I used “bQ_szBgX-gE” for my test, but what the function got was “bQ%5FszBgX%2DgE”. So I had to run playerapiid through the decodeURIComponent function before I was able to do anything with it.
  2. I forgot to tell YouTube which version I was using. This seems pretty stupid, but the results kept pointing to the same conclusion. The URL I was using for the swf looked something like this: “”. In order to make it work, I had to add “&version=3”

Does it work if you make those changes?

terrific! that worked like a charm.

thank you very much