Ouça no player ou va para o site - Web Rádio Serra do Rio do Rastro   Músicas 24 Horas sem intervalo.

PDM Corte no MDF

<!DOCTYPE html>

<html lang="pt-BR">

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1">

<title>Câmera ao vivo</title>

<style>

  body { margin:0; background:#0f1115; color:#e8eaed; font-family:system-ui,Arial,sans-serif; }

  .wrap { max-width:960px; margin:0 auto; padding:16px; }

  h1 { font-size:20px; margin:0 0 12px; }

  .bar { display:flex; flex-wrap:wrap; gap:8px; margin-bottom:12px; }

  input, button { padding:10px; border-radius:8px; border:1px solid #333; background:#1a1d24; color:#e8eaed; font-size:14px; }

  input { flex:1; min-width:200px; }

  button { background:#2d8cff; border:0; font-weight:600; cursor:pointer; }

  button.sec { background:#333; }

  video { width:100%; aspect-ratio:16/9; background:#000; border-radius:10px; }

  #status { margin-top:8px; font-size:13px; color:#9aa0a6; }

</style>

</head>

<body>

<div class="wrap">

  <h1>📹 Câmera ao vivo</h1>

  <div class="bar">

    <input id="servidor" placeholder="Endereço do go2rtc, ex: http://192.168.1.10:1984">

    <input id="nome" value="camera" placeholder="Nome do stream" style="max-width:160px">

    <button id="iniciar">Iniciar</button>

    <button id="parar" class="sec">Parar</button>

    <button id="tela" class="sec">Tela cheia</button>

  </div>

  <video id="v" autoplay muted playsinline controls></video>

  <div id="status"></div>

</div>


<script>

const $ = id => document.getElementById(id);

let pc = null;


// Se a página for aberta pelo próprio go2rtc, o endereço já vem preenchido

$('servidor').value = location.protocol.startsWith('http') ? location.origin : 'http://localhost:1984';


function parar() {

  if (pc) { pc.close(); pc = null; }

  $('v').srcObject = null;

}


async function iniciar() {

  parar();

  const status = $('status');

  status.textContent = 'Conectando...';

  try {

    pc = new RTCPeerConnection({ iceServers: [{ urls: 'stun:stun.l.google.com:19302' }] });

    pc.addTransceiver('video', { direction: 'recvonly' });

    pc.addTransceiver('audio', { direction: 'recvonly' });

    pc.ontrack = e => { $('v').srcObject = e.streams[0]; };

    pc.onconnectionstatechange = () => { if (pc) status.textContent = 'Estado: ' + pc.connectionState; };


    await pc.setLocalDescription(await pc.createOffer());

    await new Promise(ok => {

      if (pc.iceGatheringState === 'complete') return ok();

      pc.onicegatheringstatechange = () => pc.iceGatheringState === 'complete' && ok();

      setTimeout(ok, 2000);

    });


    const url = $('servidor').value.replace(/\/$/, '') + '/api/webrtc?src=' + encodeURIComponent($('nome').value);

    const r = await fetch(url, { method: 'POST', body: pc.localDescription.sdp });

    if (!r.ok) throw new Error('go2rtc respondeu ' + r.status + ' (confira o nome do stream)');

    await pc.setRemoteDescription({ type: 'answer', sdp: await r.text() });

  } catch (e) {

    status.textContent = 'Erro: ' + e.message;

  }

}


$('iniciar').addEventListener('click', iniciar);

$('parar').addEventListener('click', parar);

$('tela').addEventListener('click', () => $('v').requestFullscreen && $('v').requestFullscreen());

if (location.protocol.startsWith('http')) iniciar();   // inicia sozinho

</script>

</body>

</html>


Deslize para escolher a área desejada