# Guia de Streaming

## Streaming desde URL

```python
from basskit.alto_nivel.reproductor import Reproductor, inicializar, liberar

inicializar()
rep = Reproductor()
rep.abrir_url("http://stream.example.com/radio.mp3")
rep.reproducir()
# rep.detener() cuando sea necesario
liberar()
```

## Streaming de bajo nivel

```python
from basskit.dlls.bass import bass
from basskit.constantes.bass import *

bass.BASS_Init(-1, 44100, 0, 0, None)

url = b"http://stream.example.com/radio.mp3"
stream = bass.BASS_StreamCreateURL(url, 0, BASS_STREAM_STATUS, None, None)
bass.BASS_ChannelPlay(stream, 0)

# Monitorear estado
estado = bass.BASS_ChannelIsActive(stream)
# BASS_ACTIVE_PLAYING, BASS_ACTIVE_STALLED, etc.

bass.BASS_StreamFree(stream)
bass.BASS_Free()
```

## Stream personalizado (push)

```python
from basskit.dlls.bass import bass
from basskit.constantes.bass import *
from basskit.callbacks.bass import STREAMPROC, mantener_callback
import ctypes, math

@STREAMPROC
def generar_seno(handle, buffer, length, user):
    datos = (ctypes.c_float * (length // 4)).from_address(buffer)
    for i in range(len(datos)):
        datos[i] = 0.5 * math.sin(2 * math.pi * 440 * i / 44100)
    return length

mantener_callback(generar_seno)

bass.BASS_Init(-1, 44100, 0, 0, None)
stream = bass.BASS_StreamCreate(44100, 1, BASS_SAMPLE_FLOAT, generar_seno, None)
bass.BASS_ChannelPlay(stream, 0)
```
