Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get YouTube video info from iFrame embed API

I'm using the YouTube iFrame API to embed videos and create a simple custom player.

I'm looking to get the video title/description/etc. from the API without having to do another call to YouTube to get the information. I am unable to find any relevant information - any thoughts, or am I stuck making an extra call to get the video info? I thought perhaps the information was available in the player object returned by YT.Player().

Thanks!

like image 463
Randy Hall Avatar asked Feb 17 '23 04:02

Randy Hall


2 Answers

As it is currently, assuming your player object is ready, video data is available via player.getVideoData() which returns the video data object from the YT.Player:

var videoData = player.getVideoData();
var title = videoData['title'];
var video_id = videoData['video_id'];
var author = videoData['author'];

Note, the title in the video data object is only a short title, 48 characters from what I can see. A long title and any description are not currently available.

like image 187
JacobFennell Avatar answered May 05 '23 05:05

JacobFennell


Here i have done with it .. If it's correct then mark as Right :)

<script type="text/javascript">
var playListURL = 'http://gdata.youtube.com/feeds/users/AbrahamLingo/uploads?alt=json&callback=?';

var videoURL= 'http://www.youtube.com/watch?v=';
$.getJSON(playListURL, function(data) {
var list_data="";
$.each(data.feed.entry, function(i, item) {
var feedTitle = item.title.$t;
var feedURL = item.link[1].href;
var fragments = feedURL.split("/");
var videoID = fragments[fragments.length - 2];
var url = videoURL + videoID;
var thumb = "http://img.youtube.com/vi/"+ videoID +"/hqdefault.jpg";
 alert(feedTitle);
});
});

</script>

Demo link :- http://jsfiddle.net/7gq6Y/

like image 26
Rushikesh jogle Avatar answered May 05 '23 04:05

Rushikesh jogle