Fetch qualities
This commit is contained in:
parent
2f1cc48b0b
commit
4a79341245
|
@ -44,6 +44,7 @@
|
||||||
// Transform available levels into an array of integers (height values).
|
// Transform available levels into an array of integers (height values).
|
||||||
const availableQualities = hls.levels.map((l) => l.height);
|
const availableQualities = hls.levels.map((l) => l.height);
|
||||||
availableQualities.unshift(0);
|
availableQualities.unshift(0);
|
||||||
|
app.ports.nowHasQualities.send(availableQualities);
|
||||||
});
|
});
|
||||||
|
|
||||||
hls.on(Hls.Events.LEVEL_SWITCHED, function (event, data) {
|
hls.on(Hls.Events.LEVEL_SWITCHED, function (event, data) {
|
||||||
|
|
11
src/Main.elm
11
src/Main.elm
|
@ -20,7 +20,7 @@ main =
|
||||||
{ init = \_ _ _ -> init
|
{ init = \_ _ _ -> init
|
||||||
, update = update
|
, update = update
|
||||||
, view = view
|
, view = view
|
||||||
, subscriptions = \_ -> Sub.none
|
, subscriptions = \_ -> nowHasQualities NowHasQualities
|
||||||
, onUrlChange = \_ -> Noop
|
, onUrlChange = \_ -> Noop
|
||||||
, onUrlRequest = \_ -> Noop
|
, onUrlRequest = \_ -> Noop
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,7 @@ type alias Model =
|
||||||
, volume : Float
|
, volume : Float
|
||||||
, muted : Bool
|
, muted : Bool
|
||||||
, isFullscreen : Bool
|
, isFullscreen : Bool
|
||||||
|
, qualities : List Int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -51,6 +52,7 @@ type Msg
|
||||||
| NowAtVolume Float Bool
|
| NowAtVolume Float Bool
|
||||||
| NowLoaded (List ( Float, Float ))
|
| NowLoaded (List ( Float, Float ))
|
||||||
| NowIsFullscreen Bool
|
| NowIsFullscreen Bool
|
||||||
|
| NowHasQualities (List Int)
|
||||||
|
|
||||||
|
|
||||||
init : ( Model, Cmd Msg )
|
init : ( Model, Cmd Msg )
|
||||||
|
@ -64,6 +66,7 @@ init =
|
||||||
1.0
|
1.0
|
||||||
False
|
False
|
||||||
False
|
False
|
||||||
|
[]
|
||||||
, initVideo ()
|
, initVideo ()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -107,6 +110,9 @@ update msg model =
|
||||||
NowIsFullscreen fullscreen ->
|
NowIsFullscreen fullscreen ->
|
||||||
( { model | isFullscreen = fullscreen }, Cmd.none )
|
( { model | isFullscreen = fullscreen }, Cmd.none )
|
||||||
|
|
||||||
|
NowHasQualities qualities ->
|
||||||
|
( { model | qualities = qualities }, Cmd.none )
|
||||||
|
|
||||||
|
|
||||||
view : Model -> Browser.Document Msg
|
view : Model -> Browser.Document Msg
|
||||||
view model =
|
view model =
|
||||||
|
@ -400,3 +406,6 @@ port requestFullscreen : () -> Cmd msg
|
||||||
|
|
||||||
|
|
||||||
port exitFullscreen : () -> Cmd msg
|
port exitFullscreen : () -> Cmd msg
|
||||||
|
|
||||||
|
|
||||||
|
port nowHasQualities : (List Int -> msg) -> Sub msg
|
||||||
|
|
Loading…
Reference in New Issue