test2023h5's picture
Upload 180 files
d95db82 verified
raw
history blame
1.57 kB
'''
title: Audio Playback
'''
import streamsync as ss
ss.md("## ss.audio")
ss.space()
ss.md('''
#### πŸ”… Example
''')
ss.space()
audiosrc = "media/test.wav"
player = ss.audio(audiosrc)
ss.space("mt-8")
ss.write('''
---
#### πŸ”Ž Code
''')
ss.md('''
```python
import simplestart as ss
audiosrc = "media/davide_quatela--breathing_barcelona.mp3"
player = ss.audio(audiosrc)
```
''')
def playaudio(event):
if event.tag == "play":
player.play()
elif event.tag == "pause":
player.pause()
elif event.tag == "change":
player.src = "media/davide_quatela--breathing_barcelona.mp3"
elif event.tag == "seek":
player.seek(3)
ss.button("play", onclick = playaudio, eventTag = "play")
ss.button("pause", onclick = playaudio, eventTag = "pause")
ss.button("change source", onclick = playaudio, eventTag = "change")
ss.button("seek", onclick = playaudio, eventTag = "seek")
ss.md('''
```python
def playaudio(event):
if event.tag == "play":
player.play()
elif event.tag == "pause":
player.pause()
elif event.tag == "change":
player.src = "media/davide_quatela--breathing_barcelona.mp3"
elif event.tag == "seek":
player.seek(3)
ss.button("play", onclick = playaudio, eventTag = "play")
ss.button("pause", onclick = playaudio, eventTag = "pause")
ss.button("change source", onclick = playaudio, eventTag = "change")
ss.button("seek", onclick = playaudio, eventTag = "seek")
```
''')
ss.md('''
::: tip
ss.audio supports audio formats including wav, mp3, etc.
:::
''')