From 22fd24c13e956ba537ecb98f96a3af67cef523fc Mon Sep 17 00:00:00 2001 From: Thomas Forgione Date: Wed, 9 Jun 2021 18:59:20 +0200 Subject: [PATCH] Fix url thingy --- index.html | 7 ++++--- src/Main.elm | 14 +++++++------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/index.html b/index.html index 0f7dc7d..742bdb3 100644 --- a/index.html +++ b/index.html @@ -31,14 +31,15 @@ } }); - var app = Elm.Main.init({ + const app = Elm.Main.init({ node: document.getElementById('container'), + flags: "video/manifest.m3u8", }); - app.ports.initVideo.subscribe(function() { + app.ports.initVideo.subscribe(function(arg) { const video = document.getElementById('video'); const hls = new Hls(); - hls.loadSource('video/manifest.m3u8'); + hls.loadSource(arg); hls.on(Hls.Events.MANIFEST_PARSED, function (event, data) { // Transform available levels into an array of integers (height values). diff --git a/src/Main.elm b/src/Main.elm index 61c9269..39f7595 100644 --- a/src/Main.elm +++ b/src/Main.elm @@ -14,10 +14,10 @@ import Icons import Json.Decode as Decode -main : Program Decode.Value Model Msg +main : Program String Model Msg main = Browser.application - { init = \_ _ _ -> init + { init = \url _ _ -> init url , update = update , view = view , subscriptions = \_ -> nowHasQualities NowHasQualities @@ -55,10 +55,10 @@ type Msg | NowHasQualities (List Int) -init : ( Model, Cmd Msg ) -init = +init : String -> ( Model, Cmd Msg ) +init url = ( Model - "video/manifest.m3u8" + url False 0.0 1.0 @@ -67,7 +67,7 @@ init = False False [] - , initVideo () + , initVideo url ) @@ -393,7 +393,7 @@ formatTime s = hoursString ++ minutesString ++ ":" ++ secsString -port initVideo : () -> Cmd msg +port initVideo : String -> Cmd msg port playPause : () -> Cmd msg