Closed Nelson-Gon closed 7 months ago
The Audio
class doesn't inherit from the ipywidgets
's Widget
class, so it won't be compatible with {shinywidgets}
, but since it has a _repr_html_
method, you can render it this way (this requires the development version of {htmltools}
):
from IPython.display import Audio
from shiny import App, render, ui
app_ui = ui.page_fluid(
ui.output_ui("my_audio"),
)
def server(input, output, session):
@render.ui
def my_audio():
return Audio("http://www.nch.com.au/acm/8k16bitpcm.wav")
app = App(app_ui, server)
Or if using the new shiny express mode, this just becomes:
from IPython.display import Audio
import shiny
import shiny.express
Audio("http://www.nch.com.au/acm/8k16bitpcm.wav")
Description
I was trying to
insert_ui
for anAudio
IPython
widget by doing something likeMy expectation was that this would recognize the generated IPython HTML and render it. It neither rendered not did it throw any error. I have played with
output_widget
andregister_widget
but it seems there is no audio support (or at least not one I am aware of) in ipywidgets. The end goal would be to have something likestreamlit
'saudio
UI but with autoplay, a feature they still lackThanks, NelsonGon