youtube_iframe_api_loader
v1.0.0
Published
Youtube iframe api Wrapper
Downloads
43
Maintainers
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
andorigin
params by this function, theyoutube 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
- Load youtube iframe api
- Function:
load_youtube_iframe_api
():Promise<any>
- Return:
window.YT
const YT = await load_youtube_iframe_api() //<-- YT = window.YT