|
|
|
@ -8,13 +8,15 @@ import Html.Events as Events
|
|
|
|
|
import Msg
|
|
|
|
|
import Types
|
|
|
|
|
import Video
|
|
|
|
|
import Types exposing (withDownload)
|
|
|
|
|
|
|
|
|
|
view : Types.Model -> Document Msg.Msg
|
|
|
|
|
view model =
|
|
|
|
|
{ title = "Minimal WebPlayer"
|
|
|
|
|
, body =
|
|
|
|
|
[ if List.length model.videos == 0 then Html.div [] [] else makeDropDown model.videos
|
|
|
|
|
, if model.selected == "" then Html.div [] [] else makePlayer model.selected
|
|
|
|
|
[ makeDropDown model.videos
|
|
|
|
|
, makePlayer model
|
|
|
|
|
, downloadList model
|
|
|
|
|
, Html.footer []
|
|
|
|
|
[ Html.text "Handmade with love (and Vim and elm) ;)"
|
|
|
|
|
, Html.a
|
|
|
|
@ -25,23 +27,40 @@ view model =
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
empty : Html.Html Msg.Msg
|
|
|
|
|
empty = Html.div [] []
|
|
|
|
|
|
|
|
|
|
makeDropDown : List Video.Video -> Html.Html Msg.Msg
|
|
|
|
|
makeDropDown videos =
|
|
|
|
|
Html.select [ Events.onInput Msg.VideoSelected ]
|
|
|
|
|
<| makeOption {title = "Select one please ;)", path = ""} :: (List.map makeOption videos)
|
|
|
|
|
if List.isEmpty videos
|
|
|
|
|
then empty
|
|
|
|
|
else
|
|
|
|
|
Html.select [ Events.onInput Msg.VideoSelected ]
|
|
|
|
|
<| makeOption {title = "Select one please ;)", path = ""} :: (List.map makeOption videos)
|
|
|
|
|
|
|
|
|
|
makeOption : Video.Video -> Html.Html Msg.Msg
|
|
|
|
|
makeOption video =
|
|
|
|
|
Html.option
|
|
|
|
|
[ Html.Attributes.value video.path ] [ Html.text video.title ]
|
|
|
|
|
|
|
|
|
|
makePlayer : String -> Html.Html Msg.Msg
|
|
|
|
|
makePlayer path =
|
|
|
|
|
Html.video
|
|
|
|
|
[ Html.Attributes.width 960
|
|
|
|
|
, Html.Attributes.height 650
|
|
|
|
|
, Html.Attributes.controls True
|
|
|
|
|
]
|
|
|
|
|
[ Html.source [Html.Attributes.src (path ++ ".mkv"), Html.Attributes.type_ "video/x-matroska"] []
|
|
|
|
|
, Html.source [Html.Attributes.src (path ++ ".mp4"), Html.Attributes.type_ "video/mp4"] []
|
|
|
|
|
]
|
|
|
|
|
makePlayer : Types.Model -> Html.Html Msg.Msg
|
|
|
|
|
makePlayer model =
|
|
|
|
|
case model.selected of
|
|
|
|
|
Nothing -> empty
|
|
|
|
|
Just path ->
|
|
|
|
|
Html.video
|
|
|
|
|
[ Html.Attributes.width 960
|
|
|
|
|
, Html.Attributes.height 650
|
|
|
|
|
, Html.Attributes.controls True
|
|
|
|
|
] <| List.map (Video.htmlSourceElem path) model.extensions
|
|
|
|
|
|
|
|
|
|
downloadList : Types.Model -> Html.Html Msg.Msg
|
|
|
|
|
downloadList model =
|
|
|
|
|
let
|
|
|
|
|
selected = if not model.withDownload then Nothing else model.selected
|
|
|
|
|
in
|
|
|
|
|
case selected of
|
|
|
|
|
Nothing -> empty
|
|
|
|
|
Just path ->
|
|
|
|
|
Html.div [ Html.Attributes.class "downloadList" ]
|
|
|
|
|
<| List.map (\e -> Video.downloadLink path e) model.extensions
|