paulirish / lite-youtube-embed

A faster youtube embed.

Home Page:https://paulirish.github.io/lite-youtube-embed/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Display the title property

djmtype opened this issue · comments

Is there any way of accessing the video's title property without an api key, then display it as part of the button screen reader text for accessibility purposes?

you can use the playlabel attribute, as described in the readme. this'll make the button label clear for assistive devices.

without an API key we can't get the video title automatically though. so you'll have to set that yourself.

also #88 is solving a different problem than i think you care about. (its more for sighted users). but FYI anyway

As a note for anyone coming across this in the future, you can—as of October 2023—retrieve a video's title programmatically using YouTube's OEmbed API. Various bits of video metadata are included, but the title key has what you need.

You can view the YouTube OEmbed JSON response for the video used in the component demos.

It's quite a heavy request for just the video title, and as such doesn't warrant inclusion in the component itself, but I wanted to share the info for anyone who may find it beneficial; I use it in my build pipieline and sprinkle the data into the component's corresponding attributes.