Skip to content Skip to sidebar Skip to footer

Related Videos With Part Contentdetails And Statistics - Youtube Api V3

I'm having a problem with retrieving related videos as thumbnails towards a specific video. In my code, I have the search->list set up correctly and returns the different titles

Solution 1:

You're referring the item in the search results. When you issued a get request to videos, you will get a response of video contentDetails and statistics. Apparently, you didn't capture the returned response.

   $.get(
                    "https://www.googleapis.com/youtube/v3/videos",
                    {
                        part: 'contentDetails, statistics',
                        id: videoId, //item.snippet.resourceId.videoId,key: 'XXXXXXXXX',
                    },

                    function(videoItem) 
                    {
                        vidDuration = videoItem.contentDetails.duration; // pass item's duration
                        viewCount = videoItem.statistics.viewCount; // pass item's view count
                    }
                );

NOTE: You can pass a string of video IDs delimited by a comma to fetch multiple video contentDetails/statistics in one request.

Post a Comment for "Related Videos With Part Contentdetails And Statistics - Youtube Api V3"