Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

youtube_iframe_api_loader

mrbaobao59ISC1.0.0TypeScript support: included

Youtube iframe api Wrapper

youtube, youtube iframe api, youtube embed api, youtube api

readme

youtube_iframe_api

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

    Example

  • 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
  2. Function: load_youtube_iframe_api(): Promise<any>
  3. Return: window.YT
    const YT = await load_youtube_iframe_api() //<-- YT = window.YT