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";
6
6
maxDownstreams : 1 ,
7
7
} ) ;
8
8
9
+ const videos : Record < string , HTMLVideoElement > = { } ;
9
10
client . $state . listen ( ( v ) => console . log ( v ) ) ;
10
11
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 ;
13
16
} ) ;
14
17
await client . connect ( "default" , `alice-${ Math . round ( Math . random ( ) * 100 ) } ` ) ;
15
18
Original file line number Diff line number Diff line change @@ -337,4 +337,10 @@ export class ClientCore {
337
337
this . #videoSender. sender . replaceTrack ( null ) ;
338
338
this . #audioSender. sender . replaceTrack ( null ) ;
339
339
}
340
+
341
+ // TODO: remove browser specific
342
+ subscribe ( video : HTMLVideoElement , participant : ParticipantMeta ) {
343
+ video . srcObject = participant . stream ;
344
+ video . autoplay = true ;
345
+ }
340
346
}
You can’t perform that action at this time.
0 commit comments