<jupyter_start><jupyter_text>WidgetStreamA [WidgetStream](api.rstipywebrtc.webrtc.VideoStream) creates a [MediaStream](api.rstipywebrtc.webrtc.MediaStream) out of any widget.<jupyter_code>from ipywebrtc import WidgetStream, VideoStream<jupyter_output><empty_output><jupyter_text>Example with pythreejs: streaming of a webgl canvas<jupyter_code>from pythreejs import Mesh, SphereGeometry, MeshLambertMaterial, PerspectiveCamera, DirectionalLight, Scene, AmbientLight, Renderer, OrbitControls
ball = Mesh(
    geometry=SphereGeometry(radius=1), 
    material=MeshLambertMaterial(color='red'),
    position=[2, 1, 0]
)

c = PerspectiveCamera(
    position=[0, 5, 5], up=[0, 1, 0],
    children=[DirectionalLight(color='white', position=[3, 5, 1], intensity=0.5)]
)

scene = Scene(children=[ball, c, AmbientLight(color='#777777')])

renderer = Renderer(
    camera=c, 
    scene=scene, 
    controls=[OrbitControls(controlling=c)]
)

renderer
# the webgl_stream will be updated after the scene has changed (so drag the above ball around if nothing happens)
webgl_stream = WidgetStream(widget=renderer)
webgl_stream
# You can limit the fps
webgl_stream2 = WidgetStream(widget=renderer, max_fps=5)
webgl_stream2<jupyter_output><empty_output><jupyter_text>Example with ipywidgets: streaming of a slider widget<jupyter_code>from ipywidgets import FloatSlider
slider = FloatSlider(
    value=7.5,
    step=0.1,
    description='Test:',
    disabled=False,
    continuous_update=False,
    orientation='horizontal',
    readout=True,
    readout_format='.1f',
)

slider
widget_stream = WidgetStream(widget=slider, max_fps=1)
widget_stream
# Close the stream
widget_stream.close()<jupyter_output><empty_output><jupyter_text>Example with ipyleaflet: streaming of a map widget<jupyter_code>from ipyleaflet import Map
m = Map(center=(46, 14), zoom=5)
m
map_stream = WidgetStream(widget=m, max_fps=1)
map_stream
map_stream.close()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10848329048843187, 'fraction_numerical': 0.018508997429305913, 'mean_word_length': 7.008230452674897, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '220288', 'license': 'MIT', 'n_tokens_mistral': 683, 'n_tokens_neox': 666, 'n_words': 141, 'path': 'docs/source/WidgetStream.ipynb', 'repo_name': 'vidartf/ipywebrtc', 'size': '1945'}