Skip to content

Commit

Permalink
add event triggers for rx.video (#2700)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lendemor authored Jun 13, 2024
1 parent 5d3eef7 commit 42f34f7
Show file tree
Hide file tree
Showing 4 changed files with 194 additions and 0 deletions.
48 changes: 48 additions & 0 deletions reflex/components/react_player/audio.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,39 @@ class Audio(ReactPlayer):
on_blur: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_buffer: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_buffer_end: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_click: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_click_preview: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_context_menu: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_disable_pip: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_double_click: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_duration: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_enable_pip: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_ended: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_error: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_focus: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
Expand Down Expand Up @@ -71,9 +95,33 @@ class Audio(ReactPlayer):
on_mouse_up: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_pause: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_play: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_playback_quality_change: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_playback_rate_change: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_progress: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_ready: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_scroll: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_seek: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_start: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_unmount: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
Expand Down
49 changes: 49 additions & 0 deletions reflex/components/react_player/react_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from __future__ import annotations

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


Expand Down Expand Up @@ -43,3 +44,51 @@ class ReactPlayer(NoSSRComponent):

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

# Called when media is loaded and ready to play. If playing is set to true, media will play immediately.
on_ready: EventHandler[lambda: []]

# Called when media starts playing.
on_start: EventHandler[lambda: []]

# Called when media starts or resumes playing after pausing or buffering.
on_play: EventHandler[lambda: []]

# 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]]

# Callback containing duration of the media, in seconds.
on_duration: EventHandler[lambda seconds: [seconds]]

# Called when media is paused.
on_pause: EventHandler[lambda: []]

# Called when media starts buffering.
on_buffer: EventHandler[lambda: []]

# Called when media has finished buffering. Works for files, YouTube and Facebook.
on_buffer_end: EventHandler[lambda: []]

# Called when media seeks with seconds parameter.
on_seek: EventHandler[lambda seconds: [seconds]]

# Called when playback rate of the player changed. Only supported by YouTube, Vimeo (if enabled), Wistia, and file paths.
on_playback_rate_change: EventHandler[lambda e0: []]

# Called when playback quality of the player changed. Only supported by YouTube (if enabled).
on_playback_quality_change: EventHandler[lambda e0: []]

# Called when media finishes playing. Does not fire when loop is set to true.
on_ended: EventHandler[lambda: []]

# Called when an error occurs whilst attempting to play media.
on_error: EventHandler[lambda: []]

# Called when user clicks the light mode preview.
on_click_preview: EventHandler[lambda: []]

# Called when picture-in-picture mode is enabled.
on_enable_pip: EventHandler[lambda: []]

# Called when picture-in-picture mode is disabled.
on_disable_pip: EventHandler[lambda: []]
49 changes: 49 additions & 0 deletions reflex/components/react_player/react_player.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ from reflex.vars import Var, BaseVar, ComputedVar
from reflex.event import EventChain, EventHandler, EventSpec
from reflex.style import Style
from reflex.components.component import NoSSRComponent
from reflex.event import EventHandler
from reflex.vars import Var

class ReactPlayer(NoSSRComponent):
Expand All @@ -34,15 +35,39 @@ class ReactPlayer(NoSSRComponent):
on_blur: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_buffer: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_buffer_end: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_click: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_click_preview: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_context_menu: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_disable_pip: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_double_click: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_duration: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_enable_pip: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_ended: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_error: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_focus: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
Expand Down Expand Up @@ -70,9 +95,33 @@ class ReactPlayer(NoSSRComponent):
on_mouse_up: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_pause: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_play: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_playback_quality_change: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_playback_rate_change: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_progress: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_ready: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_scroll: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_seek: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_start: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_unmount: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
Expand Down
48 changes: 48 additions & 0 deletions reflex/components/react_player/video.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,39 @@ class Video(ReactPlayer):
on_blur: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_buffer: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_buffer_end: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_click: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_click_preview: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_context_menu: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_disable_pip: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_double_click: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_duration: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_enable_pip: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_ended: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_error: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_focus: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
Expand Down Expand Up @@ -71,9 +95,33 @@ class Video(ReactPlayer):
on_mouse_up: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_pause: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_play: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_playback_quality_change: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_playback_rate_change: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_progress: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_ready: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_scroll: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_seek: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_start: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_unmount: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
Expand Down

0 comments on commit 42f34f7

Please sign in to comment.