|
@@ -2,6 +2,7 @@ from nicegui import ui
|
|
|
|
|
|
from ..documentation_tools import text_demo
|
|
|
|
|
|
+
|
|
|
def main_demo() -> None:
|
|
|
a = ui.audio('https://cdn.pixabay.com/download/audio/2022/02/22/audio_d1718ab41b.mp3')
|
|
|
a.on('ended', lambda _: ui.notify('Audio playback completed'))
|
|
@@ -9,17 +10,13 @@ def main_demo() -> None:
|
|
|
ui.button(on_click=lambda: a.props('muted'), icon='volume_off').props('outline')
|
|
|
ui.button(on_click=lambda: a.props(remove='muted'), icon='volume_up').props('outline')
|
|
|
|
|
|
-url_audio = "https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3"
|
|
|
-seek_audio = 0
|
|
|
|
|
|
def more() -> None:
|
|
|
- @text_demo('Audio with play/pause/seek controls', '''
|
|
|
- This demo shows how to use play/pause/seek controls.
|
|
|
+ @text_demo('Control the audio element', '''
|
|
|
+ This demo shows how to play, pause and seek programmatically.
|
|
|
''')
|
|
|
def control_demo() -> None:
|
|
|
- a = ui.audio(url_audio)
|
|
|
- with ui.row():
|
|
|
- ui.button('Play', on_click=lambda: a.play())
|
|
|
- ui.button('Pause', on_click=lambda: a.pause())
|
|
|
- ui.button('Seek', on_click=lambda: a.seek(seek_audio))
|
|
|
- ui.number("Position", value=seek_audio).bind_value(globals(), 'seek_audio')
|
|
|
+ a = ui.audio('https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3')
|
|
|
+ ui.button('Play', on_click=a.play)
|
|
|
+ ui.button('Pause', on_click=a.pause)
|
|
|
+ ui.button('Jump to 0:30', on_click=lambda: a.seek(30))
|