javascript - Retrieving TITLE of current video with YouTube JS API - Stack Overflow

I have created a YouTube player with the YouTube Javascript API that loads up a playlist I have created

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 badges
Add a ment  | 

3 Answers 3

Reset to default 5

It 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条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信