Alex Rivera | Logout

How to detect blocked youtube videos through javascript

Asked 2012-05-15T18:12:19.613
8

How to detect if a youtube video is not playable?

I am aware there is a way by calling a request to the youtube api however this would take too much time to check for each video since the videos are playing on user request.

Is there a way to check on the status of the youtube player and if it does not play then act accordingly?

I know there a few status like ready, stopped, playing, qued. Couldnt find a status for this specific thing.

Thanks in advance

ok I have found the solution. But it wouldnt let me post it because im not cool enough like you guys. Here it is:

onYouTubePlayerReady = function() {
    player.addEventListener("onError", "onPlayerError");
}

function onPlayerError(errorCode) {
    playnext();
}

if you want to check for a certain error the error codes are on the youtube site. However this was enough for me.

Edit
Report

1 Answer

-1

I don't know how you did it but I did it like this:

    ...

    events{
         ...
         'onError': onPlayerError
    }

    ...

    function onPlayerError(errorCode) {
         playnext();
    }

    ...
answered 2013-07-02T11:37:04.217

Your Answer