add on progress typing to react player

This commit is contained in:
Khaleel Al-Adhami 2024-10-21 17:30:38 -07:00
parent 54ad9f0f4b
commit 98ade6a197

View File

@ -2,11 +2,22 @@
from __future__ import annotations from __future__ import annotations
from typing_extensions import TypedDict
from reflex.components.component import NoSSRComponent from reflex.components.component import NoSSRComponent
from reflex.event import EventHandler, empty_event, identity_event from reflex.event import EventHandler, empty_event, identity_event
from reflex.vars.base import Var from reflex.vars.base import Var
class Progress(TypedDict):
"""Callback containing played and loaded progress as a fraction, and playedSeconds and loadedSeconds in seconds."""
played: float
playedSeconds: float
loaded: float
loadedSeconds: float
class ReactPlayer(NoSSRComponent): class ReactPlayer(NoSSRComponent):
"""Using react-player and not implement all props and callback yet. """Using react-player and not implement all props and callback yet.
reference: https://github.com/cookpete/react-player. reference: https://github.com/cookpete/react-player.
@ -55,7 +66,7 @@ class ReactPlayer(NoSSRComponent):
on_play: EventHandler[empty_event] on_play: EventHandler[empty_event]
# Callback containing played and loaded progress as a fraction, and playedSeconds and loadedSeconds in seconds. eg { played: 0.12, playedSeconds: 11.3, loaded: 0.34, loadedSeconds: 16.7 } # Callback containing played and loaded progress as a fraction, and playedSeconds and loadedSeconds in seconds. eg { played: 0.12, playedSeconds: 11.3, loaded: 0.34, loadedSeconds: 16.7 }
on_progress: EventHandler[lambda progress: [progress]] on_progress: EventHandler[identity_event(Progress)]
# Callback containing duration of the media, in seconds. # Callback containing duration of the media, in seconds.
on_duration: EventHandler[identity_event(float)] on_duration: EventHandler[identity_event(float)]