diff --git a/www/webrtc/index.html b/www/webrtc/index.html index d4eb1776..0ff074f4 100644 --- a/www/webrtc/index.html +++ b/www/webrtc/index.html @@ -18,11 +18,19 @@ -
+
+ 已存在的流列表,点击自动播放: +
    +
  1. 初始演示
  2. +
  3. 每秒自动刷新
  4. +
+
+ +

- +

@@ -252,6 +260,64 @@ } } + + function on_click_to_play(app, stream) { + console.log(`on_click_to_play: ${app}/${stream}`); + var url = `${document.location.protocol}//${window.location.host}/index/api/webrtc?app=${app}&stream=${stream}&type=play`; + document.getElementById('streamUrl').value = url; + start(); + } + function clearStreamList() { + let content = document.getElementById("olstreamlist"); + while (content.hasChildNodes()) { + content.removeChild(content.firstChild); + } + } + function fillStreamList(json) { + clearStreamList(); + if (json.code != 0) { + return; + } + let ss = {}; + for (let o of json.data) { + if (ss[o.app]) { + ss[o.app].add(o.stream); + } else { + let set = new Set(); + set.add(o.steram); + ss[o.app] = set; + } + } + + for (let o in ss) { + let app = o; + for (let s of ss[o]) { + if (s) { + //console.log(app, s); + let content = document.getElementById("olstreamlist"); + let child = `

  • ${app}/${s}
  • `; + content.insertAdjacentHTML("beforeend", child); + } + } + } + } + async function getData(url) { + const response = await fetch(url, { + method: 'GET' + }); + const data = await response.json(); + //console.log(data); + return data; + } + function get_media_list() { + let url = document.location.protocol+"//"+window.location.host+"/index/api/getMediaList?secret=035c73f7-bb6b-4889-a715-d9eb2d1925cc"; + let json = getData(url); + json.then((json)=> fillStreamList(json)); + } + setInterval(() => { + get_media_list(); + }, 1000); +