youtube_iframe_api_loader
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

youtube_iframe_api

  • This package is a wrapper for youtube iframe api
  • From youtube: https://developers.google.com/youtube/iframe_api_reference link

Example

  1. Enable Youtube iframe api
  • Function: enable_youtube_iframe_api({src, origin}): string
  • MUST HAVE: We must add enablejsapi and origin params by this function, the youtube iframe api will be able to work properly
const src = "https://youtu.be/PDCiOpxCrpw?si=ubXxpnlnAQF6N0gD"
src = enable_youtube_iframe_api({src, origin: "http://example.com:3000"}) //<-- src + "&enablejsapi=1&origin=" + origin
  1. Load youtube iframe api
  • Function: load_youtube_iframe_api(): Promise<any>
  • Return: window.YT
const YT = await load_youtube_iframe_api() //<-- YT = window.YT

Package Sidebar

Install

npm i youtube_iframe_api_loader

Weekly Downloads

20

Version

1.0.0

License

ISC

Unpacked Size

16.1 kB

Total Files

26

Last publish

Collaborators

  • mrbaobao