video_documentation.py 837 B

1234567891011121314151617181920
  1. from nicegui import ui
  2. from ...model import UiElementDocumentation
  3. class VideoDocumentation(UiElementDocumentation, element=ui.video):
  4. def main_demo(self) -> None:
  5. v = ui.video('https://test-videos.co.uk/vids/bigbuckbunny/mp4/h264/360/Big_Buck_Bunny_360_10s_1MB.mp4')
  6. v.on('ended', lambda _: ui.notify('Video playback completed'))
  7. def more(self) -> None:
  8. @self.demo('Control the video element', '''
  9. This demo shows how to play, pause and seek programmatically.
  10. ''')
  11. def control_demo() -> None:
  12. v = ui.video('https://test-videos.co.uk/vids/bigbuckbunny/mp4/h264/360/Big_Buck_Bunny_360_10s_1MB.mp4')
  13. ui.button('Play', on_click=v.play)
  14. ui.button('Pause', on_click=v.pause)
  15. ui.button('Jump to 0:05', on_click=lambda: v.seek(5))