video_documentation.py 699 B

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