summaryrefslogtreecommitdiff
path: root/source/client/user.ts
diff options
context:
space:
mode:
Diffstat (limited to 'source/client/user.ts')
-rw-r--r--source/client/user.ts21
1 files changed, 21 insertions, 0 deletions
diff --git a/source/client/user.ts b/source/client/user.ts
index b7ee24a..7d6991a 100644
--- a/source/client/user.ts
+++ b/source/client/user.ts
@@ -1,3 +1,4 @@
+import { log } from "./logger"
import { Room } from "./room"
@@ -20,6 +21,26 @@ export abstract class User {
this.update_view()
}
+ add_track(t: MediaStreamTrack) {
+ this.stream.addTrack(t)
+ this.update_view()
+ t.onended = () => {
+ log("media", "track ended", t)
+ this.stream.removeTrack(t)
+ this.update_view()
+ }
+ t.onmute = () => {
+ log("media", "track muted", t)
+ this.stream.removeTrack(t)
+ this.update_view()
+ }
+ t.onunmute = () => {
+ log("media", "track unmuted", t)
+ this.stream.addTrack(t)
+ this.update_view()
+ }
+ }
+
update_view() {
if (this.view_el) this.el.removeChild(this.view_el)
this.view_el = this.create_view()