Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Youtube Player API Throws 404

This has been bugging me for a while now, I am using this generic script to create a player

var player = new YT.Player(videoArray[0], { videoId : videoArray[0], events : { 'onStateChange' : onPlayerStateChange } });

I have the callback function set up with just a simple console.log the problem is when I change the state of a player the console throws

https://www.youtube.com/get_video?noflv=1&video_id=ghUA.... GET 404 from the file html5player-en_US-vfloyxzv5.js:39 witch I asume is loaded by the YouTube Iframe API.

Any ideeas or posibile solutions will be greatly apreciated.

like image 886
Marius Ilie Avatar asked Jun 12 '14 06:06

Marius Ilie


2 Answers

Sadly, this is one of the numerous little things you'll have to cope with using the Youtube Player API. I don't think there is any solution, and we can only wait for a Youtube fix.

A bug report has already been created, feel free to vote for it.

Youtube player is updated every tuesday. Hopefully, this will be fixed someday.

like image 189
gnou Avatar answered Nov 15 '22 19:11

gnou


I found out what I was doing wrong, I am posting this maybe it will help someone along the way.

Since the videoArray was holding jQuery object, I used this piece of code to get it all working.

    if(isYouTubeVideo) {
        videoID = iframeSrc.substr(baseUrlLength);
    }

    videoArray[i] = {};
    videoArray[i].id = videoID;

    jQuery.ajax({
    dataType: 'JSON',
    url: 'https://gdata.youtube.com/feeds/api/videos/' + videoID + '?v=2&alt=json'
    })
    .done(function(data) {
        videoArray[i].title = data.entry.title.$t;
    });

    jQuery(this).attr('id', videoID);
    playerArray[i] = new YT.Player(videoArray[i].id, { event : //Events here})

I hope this helps someone :)

like image 41
Marius Ilie Avatar answered Nov 15 '22 21:11

Marius Ilie