最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Youtube Player API Throws 404 - Stack Overflow

programmeradmin5浏览0评论

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

;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.

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./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.

Share Improve this question asked Jun 12, 2014 at 6:31 Marius IlieMarius Ilie 2202 silver badges13 bronze badges 1
  • 1 I'm having the same issue. Does anyone have a solution for this ? – Mevin Babu Commented Jul 26, 2014 at 4:24
Add a ment  | 

3 Answers 3

Reset to default 4

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.

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./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 :)

I get this for certain videos. In my experience, the get_video 404 doesn't matter - the video still loads correctly.

There is one random caveat though; if you're running this on an iPhone connected to Mac Safari Web Inspector, the 404 causes the video to stop loading. This caused me hours of fun!

发布评论

评论列表(0)

  1. 暂无评论