Metadata-Version: 2.4
Name: gradio_hls_player
Version: 0.0.1
Summary: Python library for easily interacting with trained machine learning models
Author-email: YOUR NAME <YOUREMAIL@domain.com>
License-Expression: Apache-2.0
Keywords: gradio-custom-component,gradio-template-Fallback
Classifier: Development Status :: 3 - Alpha
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Scientific/Engineering :: Visualization
Requires-Python: >=3.8
Requires-Dist: gradio<6.0,>=4.0
Provides-Extra: dev
Requires-Dist: build; extra == 'dev'
Requires-Dist: twine; extra == 'dev'
Description-Content-Type: text/markdown

---
tags: [gradio-custom-component, ]
title: gradio_gradio_hls_player
short_description: A gradio custom component
colorFrom: blue
colorTo: yellow
sdk: gradio
pinned: false
app_file: space.py
---

# `gradio_hls_player`
<img alt="Static Badge" src="https://img.shields.io/badge/version%20-%200.0.1%20-%20orange">  

Python library for easily interacting with trained machine learning models

## Installation

```bash
pip install gradio_hls_player
```

## Usage

```python
import gradio as gr
from gradio_hls_player import GradioHLSPlayer

def create_hls_app():
    with gr.Blocks() as demo:
        gr.Markdown("# Gradio HLS Stream Player")
        
        with gr.Row():
            url_input = gr.Textbox(
                label="Enter M3U8 URL",
                value="https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8",
                placeholder="Paste HLS stream URL here..."
            )
            submit_btn = gr.Button("Load Stream", variant="primary")
        
        with gr.Row():
            width_slider = gr.Slider(
                label="Width", 
                minimum=320, 
                maximum=1920, 
                value=640, 
                step=10
            )
            height_slider = gr.Slider(
                label="Height", 
                minimum=180, 
                maximum=1080, 
                value=360, 
                step=10
            )
        
        autoplay_checkbox = gr.Checkbox(label="Autoplay", value=False)
        hide_controls_checkbox = gr.Checkbox(label="Hide Controls", value=False)
        
        hls_player = GradioHLSPlayer(
            value={
                "url": "https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8",
                "width": 640,
                "height": 360,
                "autoplay": False,
                "hide_player_control_bar": False
            },
            label="HLS Video Player"
        )
        
        def update_player(url, width, height, autoplay, hide_controls):
            return {
                "url": url,
                "width": width,
                "height": height,
                "autoplay": autoplay,
                "hide_player_control_bar": hide_controls
            }

        url_input.change(
            fn=update_player,
            inputs=[url_input, width_slider, height_slider, autoplay_checkbox, hide_controls_checkbox],
            outputs=hls_player
        )
        submit_btn.click(
            fn=update_player,
            inputs=[url_input, width_slider, height_slider, autoplay_checkbox, hide_controls_checkbox],
            outputs=hls_player
        )
    
    return demo

if __name__ == "__main__":
    app = create_hls_app()
    app.launch()
```

## `GradioHLSPlayer`

### Initialization

<table>
<thead>
<tr>
<th align="left">name</th>
<th align="left" style="width: 25%;">type</th>
<th align="left">default</th>
<th align="left">description</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left"><code>value</code></td>
<td align="left" style="width: 25%;">

```python
typing.Dict[str, typing.Any][str, typing.Any]
```

</td>
<td align="left"><code>None</code></td>
<td align="left">None</td>
</tr>
</tbody></table>


### Events

| name | description |
|:-----|:------------|
| `play` |  |
| `pause` |  |
| `error` |  |



### User function

The impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).

- When used as an Input, the component only impacts the input signature of the user function.
- When used as an output, the component only impacts the return signature of the user function.

The code snippet below is accurate in cases where the component is used as both an input and an output.

- **As output:** Is passed, the preprocessed input data sent to the user's function in the backend.
- **As input:** Should return, the output data received by the component from the user's function in the backend.

 ```python
 def predict(
     value: typing.Dict[str, typing.Any][str, typing.Any]
 ) -> typing.Dict[str, typing.Any][str, typing.Any]:
     return value
 ```
 
