Browse Source

#555 allow looping audio and video

Falko Schindler 2 years ago
parent
commit
9f8002a92a
2 changed files with 14 additions and 2 deletions
  1. 7 1
      nicegui/elements/audio.py
  2. 7 1
      nicegui/elements/video.py

+ 7 - 1
nicegui/elements/audio.py

@@ -7,7 +7,11 @@ register_component('audio', __file__, 'audio.js')
 class Audio(Element):
 
     def __init__(self, src: str, *,
-                 type: str = 'audio/mpeg', controls: bool = True, autoplay: bool = False, muted: bool = False) -> None:
+                 type: str = 'audio/mpeg',
+                 controls: bool = True,
+                 autoplay: bool = False,
+                 muted: bool = False,
+                 loop: bool = False) -> None:
         """Audio
 
         :param src: URL of the audio source
@@ -15,6 +19,7 @@ class Audio(Element):
         :param controls: whether to show the audio controls, like play, pause, and volume (default: `True`)
         :param autoplay: whether to start playing the audio automatically (default: `False`)
         :param muted: whether the audio should be initially muted (default: `False`)
+        :param loop: whether the audio should loop (default: `False`)
 
         See `here <https://developer.mozilla.org/en-US/docs/Web/HTML/Element/audio#events>`_
         for a list of events you can subscribe to using the generic event subscription `on()`.
@@ -25,3 +30,4 @@ class Audio(Element):
         self._props['controls'] = controls
         self._props['autoplay'] = autoplay
         self._props['muted'] = muted
+        self._props['loop'] = loop

+ 7 - 1
nicegui/elements/video.py

@@ -7,7 +7,11 @@ register_component('video', __file__, 'video.js')
 class Video(Element):
 
     def __init__(self, src: str, *,
-                 type: str = 'video/mp4', controls: bool = True, autoplay: bool = False, muted: bool = False) -> None:
+                 type: str = 'video/mp4',
+                 controls: bool = True,
+                 autoplay: bool = False,
+                 muted: bool = False,
+                 loop: bool = False) -> None:
         """Video
 
         :param src: URL of the video source
@@ -15,6 +19,7 @@ class Video(Element):
         :param controls: whether to show the video controls, like play, pause, and volume (default: `True`)
         :param autoplay: whether to start playing the video automatically (default: `False`)
         :param muted: whether the video should be initially muted (default: `False`)
+        :param loop: whether the video should loop (default: `False`)
 
         See `here <https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video#events>`_
         for a list of events you can subscribe to using the generic event subscription `on()`.
@@ -25,3 +30,4 @@ class Video(Element):
         self._props['controls'] = controls
         self._props['autoplay'] = autoplay
         self._props['muted'] = muted
+        self._props['loop'] = loop