I have created a YouTube player with the YouTube Javascript API that loads up a playlist I have created.
Because the video is chromeless, it does not display controls or video info. I was hoping to pull the title of the currently playing video and display it underneath. I can pull information such as current time position, and current video duration with things like ytplayer.getDuration() and ytplayer.getCurrentTime().
Wondering if something like "ytplayer.getTitle()" might exist but be undocumented?
I have created a YouTube player with the YouTube Javascript API that loads up a playlist I have created.
Because the video is chromeless, it does not display controls or video info. I was hoping to pull the title of the currently playing video and display it underneath. I can pull information such as current time position, and current video duration with things like ytplayer.getDuration() and ytplayer.getCurrentTime().
Wondering if something like "ytplayer.getTitle()" might exist but be undocumented?
Share Improve this question asked Dec 11, 2012 at 6:08 copyflakecopyflake 7,2075 gold badges21 silver badges14 bronze badges3 Answers
Reset to default 5It is possible, for everyone that are still looking for answer of this question there is a javascript function:
player.getVideoData().title
You can't get the title from the ytplayer object, as that's really just an interface to the player controls. But you could add in a quick call to the video feed (perhaps as a part of the onPlayerReady function, but it could really be anywhere). For example, with jQuery this would only require:
$.get('http://gdata.youtube./feeds/api/videos/[videoid]?v=2&alt=json',function(data) {
title=data.entry.title.$t;
});
If you use the getVideoData method, you will get access to the title. See the codesnipped, i tried this and it printed the line below to the console.
console.log(player.getVideoData().title);
Necrotic Flesh - Prenatal Deposed
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744679066a4587504.html
评论列表(0条)