VideoLinkHelper
This is a simple library to help deal with embedded video links. It allows you to extract the ID from a video link, and can use that ID to generate an iframe to embed the video into a web application.
This library supports Youtube and Vimeo links.
Installation
This package can be installed by adding video_link_helper to your
list of dependencies in mix.exs:
def deps do
[
{:video_link_helper, "~> 0.3.0"}
]
endDocumentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/video_link_helper.
Usage
Extract an identifier from a Youtube or Vimeo URL:
VideoLinkHelper.extract_id("https://www.youtube.com/watch?v=dQw4w9WgXcQ")This will return a tuple containing the video type and the ID of the video, for example:
{:youtube, "dQw4w9WgXcQ"}A video can be embedded on a page in one of two ways:
Using the function component:
import VideoLinkHelper.VideoComponent ~H""" <.video id="dQw4w9WgXcQ" video_type="youtube" width="560" height="315" /> """Using the raw HTML function:
raw(VideoLinkHelper.render_embed("dQw4w9WgXcQ", width: 560, height: 315))
License
This is licensed under the MIT license.