tricycle / elm-embed-youtube / Embed.Youtube

Create an embedded Youtube video using the Iframe Player Api

Youtube


type alias Youtube =
Internal.Youtube.Youtube

The type of an Youtube image


type alias Attribute =
Internal.Attribute.Attribute

The type of a Youtube Attribute

Creation

fromUrl : Url -> Maybe Youtube

Attempt to create a new Youtube

from an (Youtube) Url containing the v= param. https://www.youtube.com/watch?v=0D7GrGrN1bg

import Url

Url.fromString "https://www.youtube.com/watch?v=0D7GrGrN1bg"
|> Maybe.andThen fromUrl
--> Just <| fromString "0D7GrGrN1bg"

or from shortend links such as; https://youtu.be/0D7GrGrN1bg

import Url

Url.fromString "https://youtu.be/0D7GrGrN1bg"
|> Maybe.andThen fromUrl
--> Just <| fromString "0D7GrGrN1bg"

fromString : String -> Youtube

Create a new Youtube from a string representing a VideoId

There is no validation on the input

Attributes

Check Embed.Youtube.Attributes for all the available Attribute helpers

attributes : List Attribute -> Youtube -> Youtube

Add Attributes to your Youtube type

Html

toHtml : Youtube -> Html msg

Renders an iFrame based on your settings