3
votes

TL;DR

Setting origin prevents all video events from firing.

VEVO videos do not work with the YouTube API. Error 150.


I am developing an app using PhoneGap and we are experiencing an issue as of a couple of weeks ago (early December 2015).

When we were first developing the app, we noticed VEVO videos weren't working with our API integration and found documentation online that stated we should set the origin. We set the origin to our website (in ~November 2015) and it seemed to have fixed the issues for us. At that point in time, VEVO videos worked and the events from the videos worked (onReady, onStateChange, etc.).

However, as of a couple of weeks ago (early December 2015), the API onReady and onStateChange events were NOT firing anymore and the app not working with YouTube videos. At that point, I found that if I removed the origin: sample.com code from the playerVars section of the new YT.Player, the onReady and onStateChange events worked again, but VEVO videos did not.

I have also tried every other solution that people have offered to no avail. As it stands, we can not play VEVO videos with the YouTube API no matter what we try. When the API tries to play VEVO videos, it spits out an error code "150". Also, if we set the origin, it completely breaks the YouTube API events and thus our app ceases to function.

This MUST be some sort of change on YouTube's end as we noticed this issue pop up without changing any code in the app.

Please help as now we have hit a brick wall with our app.

VEVO strikes again...


Below is some of the code that we use to create the YT Player.

//load YT api asynchronously
var yt_tag = document.createElement('script');
yt_tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(yt_tag, firstScriptTag);    

yt_player = new YT.Player(playlist[playlist_index].yt_id, {
                height : '220',
                width : (jQuery('#playlist').width() * .98),
                videoId : playlist[playlist_index].yt_id,
                playerVars : {
                    //controls: 0,
                    //'enablejsapi' : 1,
                    'wmode' : 'transparent',
                    //'origin' : 'http://example.com',
                    //'rel' : 0
                },
                //autoPlay: true,
                events : {
                    'onError' : function(event) {
                        if (dev_mode) alert(event.data);
                    },
                    'onReady' : function(yt_event) {
                        //this doesnt work
                    },
                    'onStateChange' : function(event) {
                        //this doesnt work
                    }
                }
            });
2
Such a wonderful thing that Google offers support for their APIs... sarcasmBigBrother6
running into this same problem on ionic, did you ever get a solution to this other than using the native android youtube library?CBerg

2 Answers

1
votes

I tried to recreate it using the sample html in the youtube iframe api reference (by changing the video id into a vevo video). I get pretty much the same error.

errorcode=150&reason=This+video+contains+content+from+VEVO.+It+is+restricted+from+playback+on+certain+sites.%3Cbr%2F%3E%3Cu%3E%3Ca+href%3D%27http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DdqbDc_pPz5E%26feature%3Dplayer_embedded%27+target%3D%27_blank%27%3EWatch+on+YouTube%3C%2Fa%3E%3C%2Fu%3E&c=WEB&cos=X11&status=fail&atc=a%3D3%26b%3DEZgb9KYK4gp-FS7CEwnU5BC3L2U%26c%3D1450423660%26d%3D1%26e%3DdqbDc_pPz5E%26c3a%3D26%26c1a%3D1%26c6a%3D1%26hh%3DUiaK9QLmjOspFp50bvF_ht_oeqU&cbr=Chrome&eventid=bLVzVpr2KInQ4QKx3qOoCQ&errordetail=0&csi_page_type=embed&cbrver=47.0.2526.80&enablecsi=1

As stated in the documentation, Error 150 is the same as error 101 as stated here. error 101 means

101 – The owner of the requested video does not allow it to be played in embedded players.

It's beyond your control since you don't own the video. And even if you find some fix there's no guarantee that it will last.

So I suggest for you to just utilize the error code and move to the next playable item.

-1
votes

Evidently, wmode steps outside of the API -- rather, it's tied to flash itself -- and therefore doesn't need any quotes around it.

According to this answer, wmode : "opaque" did the trick for somebody. That was four years ago, though, so... that seems odd that it didn't cause you any trouble until now. It seems everything that's really cool from Google is also prone to acting extremely strange. I'm just now diving into the iFrame API, and it's so, so promising for a project that I'm working on, but its wonkiness makes me afraid to use it as a reliable solution... But I know I'll end up using it, anyway, and going insane when my extension breaks in four months.