File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -6,10 +6,13 @@ import { ClientCore } from "./lib";
66 maxDownstreams : 1 ,
77 } ) ;
88
9+ const videos : Record < string , HTMLVideoElement > = { } ;
910 client . $state . listen ( ( v ) => console . log ( v ) ) ;
1011 client . $participants . listen ( ( newValue , _ , changed ) => {
11- // assign this to a video element
12- console . log ( changed ) ;
12+ const video = videos [ changed ] || document . createElement ( "video" ) ;
13+ const participant = newValue [ changed ] . get ( ) ;
14+ client . subscribe ( video , participant ) ;
15+ videos [ changed ] = video ;
1316 } ) ;
1417 await client . connect ( "default" , `alice-${ Math . round ( Math . random ( ) * 100 ) } ` ) ;
1518
Original file line number Diff line number Diff line change @@ -337,4 +337,10 @@ export class ClientCore {
337337 this . #videoSender. sender . replaceTrack ( null ) ;
338338 this . #audioSender. sender . replaceTrack ( null ) ;
339339 }
340+
341+ // TODO: remove browser specific
342+ subscribe ( video : HTMLVideoElement , participant : ParticipantMeta ) {
343+ video . srcObject = participant . stream ;
344+ video . autoplay = true ;
345+ }
340346}
You can’t perform that action at this time.
0 commit comments