Ver código fonte

Slightly better streams maybe

master
Roderic Day 4 anos atrás
pai
commit
08b7fb4b0a
2 arquivos alterados com 9 adições e 1 exclusões
  1. +5
    -1
      apps/rpc.js
  2. +4
    -0
      apps/streams.js

+ 5
- 1
apps/rpc.js Ver arquivo

@@ -4,6 +4,10 @@ const streams = {}
const screen = {}

function setStream({source, stream}) {
if(streams[source] && streams[source].id !== stream.id) {
streams[source].getTracks().forEach(track => track.stop())
}

streams[source] = stream
m.redraw()

@@ -68,7 +72,7 @@ async function handlePeerInfo({source: target, value}) {
const stream = streams[State.username]
if(stream) {
stream.getTracks().forEach(track => {
try {rpc.addTrack(track, stream) }
try { rpc.addTrack(track, stream) }
catch { }
})
}

+ 4
- 0
apps/streams.js Ver arquivo

@@ -38,6 +38,10 @@ const requestStream = async () => {
)
.catch(e => console.log(e))
}
else {
const stream = new MediaStream()
signal({kind: 'stream', value: {source: State.username, stream}})
}
}
const Video = {
setUp: (username) => ({dom}) => {

Carregando…
Cancelar
Salvar