@cuisine/video-helper
v1.0.2
Published
Collection of helper functions to generate embed urls for videos from different providers (vimeo, youtube, etc.)
Downloads
2
Readme
video-helper
Embed url generator for video streaming platforms.
Currently supported platforms:
- youtube
- vimeo
How to install
npm install @cuisine/video-helper
generateEmbedUrl(url: string)
Receives an url from a video provider and returns the provider specific embed url
Supported url formats
- Youtube
- https://www.youtube.com/watch?v=123456
- https://www.youtube.com/watch?v=123456?t=1
- https://www.youtube.com/shorts/123456
- https://www.youtube.com/shorts/123456?t=1
- https://youtu.be/123456
- Vimeo
- https://vimeo.com/123456
- https://vimeo.com/123456/whatever
- https://player.vimeo.com/video/123456
Example
generateEmbedUrl("https://www.youtube.com/watch?v=123456")
will output https://www.youtube.com/embed/123456
generateEmbedUrlFromProvider(id: string, provider: VideoProvider)
Receives a video id and a specific provider (from the list of supported providers) and returns the provider specific embed url
Supported providers
- youtube
- vimeo
Example
generateEmbedUrlFromProvider("123456", "youtube")
will output https://www.youtube.com/embed/123456