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!
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.
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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With