javascript/youtube api check state for playback restrictions -
Javascript / YouTube API check status for playback restrictions
The problem is that I embed from gdata / youtube-api and sometimes it does not allow playback video restrictions or embeds, so I was checking a state or something to handle it. I & amp; Tried to add format = 5 & Amp; -1 Trying an event with any luck, any idea will be highly appreciated. Function on PlayerState Change (Event) {if (event.data == -1) {// Rest of code}} Thanks in advance.
Edit3 / Solution to this problem: As you have on-set that function for the function on Capture Event and on-screen error, this problem was resolved. PlayerError (event) {if (event.data === 150} event.data === 101} {// left here}}
Edit: Add more Edit code 2: Error code matching is the only answer to the problem that I do not know how to capture the error code to any idea?
}
Loading the json data about you Videos before embedding and checking restrictions:
var xmlhttp = new XMLHttpRequest (); Var url = 'http://gdata.youtube.com/feeds/api/videos?v=2&alt=jsonc&q=TJC-subagTg'; Xmlhttp.onreadystatechange = function () {if (xmlhttp.readyState == 4 & xmlhttp.status == 200} {var response = JSON.parse (xmlhttp.responseText); Console.log (response.data.items [0] .accessControl); Console.log (response.data.items [0] .restrictions); }} Xmlhttp.open ("GET", url, true); Xmlhttp.send ();
Comments
Post a Comment