paulirish / lite-youtube-embed

A faster youtube embed.
https://paulirish.github.io/lite-youtube-embed/
Other
5.68k stars 260 forks source link

Display the title property #100

Closed djmtype closed 2 years ago

djmtype commented 2 years ago

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?

paulirish commented 2 years ago

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

heyainsleymae commented 9 months ago

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.