Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add event triggers for rx.video #2700

Merged
merged 6 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 18 additions & 15 deletions reflex/components/react_player/audio.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -32,49 +32,52 @@ class Audio(ReactPlayer):
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
on_blur: Optional[
onBuffer: Optional[
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these supposed to be camel case? or did they just not get regenerated?

Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_click: Optional[
onBufferEnd: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_context_menu: Optional[
onDisablePIP: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_double_click: Optional[
onDuration: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_focus: Optional[
onEnablePIP: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_mount: Optional[
onPause: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_mouse_down: Optional[
onPlay: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_mouse_enter: Optional[
onPlaybackQualityChange: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_mouse_leave: Optional[
onPlaybackRateChange: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_mouse_move: Optional[
onProgress: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_mouse_out: Optional[
onReady: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_mouse_over: Optional[
onSeek: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_mouse_up: Optional[
onStart: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_scroll: Optional[
on_click_preview: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_unmount: Optional[
on_ended: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_error: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
**props
Expand Down
27 changes: 27 additions & 0 deletions reflex/components/react_player/react_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from __future__ import annotations

from typing import Any, Dict

from reflex.components.component import NoSSRComponent
from reflex.vars import Var

Expand Down Expand Up @@ -43,3 +45,28 @@ class ReactPlayer(NoSSRComponent):

# Set the height of the player: ex:640px
height: Var[str]

def get_event_triggers(self) -> Dict[str, Any]:
"""Get the event triggers.

Returns:
The event triggers.
"""
return {
"onReady": lambda: [],
Lendemor marked this conversation as resolved.
Show resolved Hide resolved
"onStart": lambda: [],
"onPlay": lambda: [],
"onProgress": lambda e0: [e0],
"onDuration": lambda e0: [e0],
"onPause": lambda: [],
"onBuffer": lambda: [],
"onBufferEnd": lambda: [],
"onSeek": lambda second: [second],
"onPlaybackRateChange": lambda e0: [],
"onPlaybackQualityChange": lambda e0: [],
"on_ended": lambda: [], # do not fire if loop=True
"on_error": lambda: [],
"on_click_preview": lambda: [],
"onEnablePIP": lambda: [],
"onDisablePIP": lambda: [],
}
35 changes: 20 additions & 15 deletions reflex/components/react_player/react_player.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ from typing import Any, Dict, Literal, Optional, Union, overload
from reflex.vars import Var, BaseVar, ComputedVar
from reflex.event import EventChain, EventHandler, EventSpec
from reflex.style import Style
from typing import Any, Dict
from reflex.components.component import NoSSRComponent
from reflex.vars import Var

class ReactPlayer(NoSSRComponent):
def get_event_triggers(self) -> Dict[str, Any]: ...
@overload
@classmethod
def create( # type: ignore
Expand All @@ -31,49 +33,52 @@ class ReactPlayer(NoSSRComponent):
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
on_blur: Optional[
onBuffer: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_click: Optional[
onBufferEnd: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_context_menu: Optional[
onDisablePIP: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_double_click: Optional[
onDuration: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_focus: Optional[
onEnablePIP: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_mount: Optional[
onPause: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_mouse_down: Optional[
onPlay: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_mouse_enter: Optional[
onPlaybackQualityChange: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_mouse_leave: Optional[
onPlaybackRateChange: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_mouse_move: Optional[
onProgress: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_mouse_out: Optional[
onReady: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_mouse_over: Optional[
onSeek: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_mouse_up: Optional[
onStart: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_scroll: Optional[
on_click_preview: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_unmount: Optional[
on_ended: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_error: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
**props
Expand Down
33 changes: 18 additions & 15 deletions reflex/components/react_player/video.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -32,49 +32,52 @@ class Video(ReactPlayer):
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
on_blur: Optional[
onBuffer: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_click: Optional[
onBufferEnd: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_context_menu: Optional[
onDisablePIP: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_double_click: Optional[
onDuration: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_focus: Optional[
onEnablePIP: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_mount: Optional[
onPause: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_mouse_down: Optional[
onPlay: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_mouse_enter: Optional[
onPlaybackQualityChange: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_mouse_leave: Optional[
onPlaybackRateChange: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_mouse_move: Optional[
onProgress: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_mouse_out: Optional[
onReady: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_mouse_over: Optional[
onSeek: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_mouse_up: Optional[
onStart: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_scroll: Optional[
on_click_preview: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_unmount: Optional[
on_ended: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_error: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
**props
Expand Down
Loading