diff --git a/src/static/css/index.scss b/src/static/css/index.scss
index 55f9c80..a2db5ac 100644
--- a/src/static/css/index.scss
+++ b/src/static/css/index.scss
@@ -33,6 +33,20 @@ body {
width: 20em;
border-radius: 50%;
}
+ .content{
+ display: flex;
+ flex-direction: column;
+ gap: 1em;
+ .player{
+
+ .channel-group{
+ display: flex;
+ align-self: center;
+ justify-self: center;
+ }
+ }
+ }
+
}
diff --git a/src/static/index.html b/src/static/index.html
index 0e833d2..516f991 100644
--- a/src/static/index.html
+++ b/src/static/index.html
@@ -9,12 +9,23 @@
- Video streams
- WebRTC
-
-
-
-
+
+
+ Video streams
+ WebRTC
+
diff --git a/src/static/js/doc.ts b/src/static/js/doc.ts
index fa52d58..4289e85 100644
--- a/src/static/js/doc.ts
+++ b/src/static/js/doc.ts
@@ -1,46 +1,53 @@
-const getChannels = () => {
+const PLAYERS = 2;
+
+const populateChannels = (players:number) => {
fetch('/api/list').then(async (res) => {
const channelNames: string[] = await res.json()
- const radioGroup = document.getElementById('channel-group');
- if (!radioGroup) {
- throw new Error("Radio group not found")
+
+
+ for(let i = 0; i < players; ++i){
+ const radioGroup = document.getElementById(`channel-container-${i}`);
+ if (!radioGroup) {
+ throw new Error("Radio group not found")
+ }
+ radioGroup.innerHTML = ''
+ channelNames.forEach((channelName,_) => {
+ const id = `radio-${channelName}`;
+
+ const input = document.createElement('input');
+ input.type = "radio"
+ input.name = `channel-radio-${i}`;
+ input.value = channelName;
+ input.id = id
+
+
+ const lbl = document.createElement("label");
+ lbl.htmlFor = id;
+ lbl.textContent = channelName;
+
+ // Wrap in a div or line
+ const wrapper = document.createElement("div");
+ wrapper.appendChild(input);
+ wrapper.appendChild(lbl);
+
+
+
+ radioGroup.appendChild(wrapper)
+ })
}
- radioGroup.innerHTML = ''
- channelNames.forEach((channelName,index) => {
- const id = `radio-${index}`;
-
- const input = document.createElement('input');
- input.type = "radio"
- input.name = 'grp';
- input.value = channelName;
- input.id = id
-
-
- const lbl = document.createElement("label");
- lbl.htmlFor = id;
- lbl.textContent = channelName;
-
- // Wrap in a div or line
- const wrapper = document.createElement("div");
- wrapper.appendChild(input);
- wrapper.appendChild(lbl);
-
-
-
- radioGroup.appendChild(wrapper)
- })
+
}).catch(err => {
console.log("nope ",err)
})
}
-const tune = () =>{
- const choice = document.querySelector('input[name="grp"]:checked')
+const tune = (adapter=0) =>{
+ const choice = document.querySelector(`input[name="channel-radio-${adapter}"]:checked`)
const channel = choice?.value;
if(channel){
- fetch(`/api/tune/${channel}`, {method:'PUT'})
+ fetch(`/api/tune/${channel}?adapter=${adapter}`, {method:'PUT'})
}
}
-getChannels();
\ No newline at end of file
+populateChannels(PLAYERS);
\ No newline at end of file
diff --git a/src/static/js/video.ts b/src/static/js/video.ts
index 276a004..69312de 100644
--- a/src/static/js/video.ts
+++ b/src/static/js/video.ts
@@ -1,7 +1,8 @@
const host = window.location.hostname
const ws = new WebSocket(`ws://${host}:3001`);
const pc = new RTCPeerConnection({ iceServers: [] });
-const video = document.getElementById('video') as HTMLVideoElement;
+const video0 = document.getElementById('video0') as HTMLVideoElement;
+const video1 = document.getElementById('video1') as HTMLVideoElement;
pc.onconnectionstatechange = (event) => {
console.log("onconnectionstatechange ", event)
@@ -13,7 +14,8 @@ pc.ondatachannel = (event) => {
pc.ontrack = (event) => {
console.log("Received track event", event.streams);
- video.srcObject = event.streams[0];
+ video0.srcObject = event.streams[0];
+ video1.srcObject = event.streams[0];
};
pc.onicecandidate = ({ candidate }) => {