Fetch qualities

This commit is contained in:
Thomas Forgione 2021-06-09 17:27:52 +02:00
parent 2f1cc48b0b
commit 4a79341245
2 changed files with 11 additions and 1 deletions

View File

@ -44,6 +44,7 @@
// Transform available levels into an array of integers (height values).
const availableQualities = hls.levels.map((l) => l.height);
availableQualities.unshift(0);
app.ports.nowHasQualities.send(availableQualities);
});
hls.on(Hls.Events.LEVEL_SWITCHED, function (event, data) {

View File

@ -20,7 +20,7 @@ main =
{ init = \_ _ _ -> init
, update = update
, view = view
, subscriptions = \_ -> Sub.none
, subscriptions = \_ -> nowHasQualities NowHasQualities
, onUrlChange = \_ -> Noop
, onUrlRequest = \_ -> Noop
}
@ -35,6 +35,7 @@ type alias Model =
, volume : Float
, muted : Bool
, isFullscreen : Bool
, qualities : List Int
}
@ -51,6 +52,7 @@ type Msg
| NowAtVolume Float Bool
| NowLoaded (List ( Float, Float ))
| NowIsFullscreen Bool
| NowHasQualities (List Int)
init : ( Model, Cmd Msg )
@ -64,6 +66,7 @@ init =
1.0
False
False
[]
, initVideo ()
)
@ -107,6 +110,9 @@ update msg model =
NowIsFullscreen fullscreen ->
( { model | isFullscreen = fullscreen }, Cmd.none )
NowHasQualities qualities ->
( { model | qualities = qualities }, Cmd.none )
view : Model -> Browser.Document Msg
view model =
@ -400,3 +406,6 @@ port requestFullscreen : () -> Cmd msg
port exitFullscreen : () -> Cmd msg
port nowHasQualities : (List Int -> msg) -> Sub msg