1import { Controller } from "@hotwired/stimulus" 2 3export default class extends Controller { 4 static values = { 5 sessionId: String, 6 local: false, 7 pinned: false, 8 mirror: false, 9 videoPlayable: false, 10 screenSharePlayable: false, 11 name: "", 12 audioLevel: 0, 13 } 14 15 static targets = [ 16 "video", "blurredVideo", "screenShareVideo", "audio", "cameraOff", 17 "nameBadge", 18 ] 19 20 connect() { 21 this.videoTrack = null 22 this.screenShareTrack = null 23 this.audioTrack = null 24 25 if (this.localValue && this.hasAudioTarget) this.audioTarget.remove() 26 } 27 28 disconnect() { 29 this.destroyTracks() 30 } 31 32 nameValueChanged() { 33 if (this.hasNameBadgeTarget) this.nameBadgeTarget.textContent = this.nameValue 34 } 35 36 syncTrack(kind, track) { 37 if (kind === "video") { 38 if (this.videoTrack === track) return 39 this.videoTrack = track 40 if (track && this.hasVideoTarget) { 41 const stream = new MediaStream([track]) 42 this.videoTarget.srcObject = stream 43 if (this.hasBlurredVideoTarget) this.blurredVideoTarget.srcObject = stream 44 this.videoPlayableValue = true 45 } else { 46 if (this.hasVideoTarget) this.videoTarget.srcObject = null 47 if (this.hasBlurredVideoTarget) this.blurredVideoTarget.srcObject = null 48 this.videoPlayableValue = false 49 } 50 } else if (kind === "screenVideo") { 51 if (this.screenShareTrack === track) return 52 this.screenShareTrack = track 53 if (track && this.hasScreenShareVideoTarget) { 54 this.screenShareVideoTarget.srcObject = new MediaStream([track]) 55 this.screenSharePlayableValue = true 56 } else { 57 if (this.hasScreenShareVideoTarget) this.screenShareVideoTarget.srcObject = null 58 this.screenSharePlayableValue = false 59 } 60 } else if (kind === "audio") { 61 if (this.audioTrack === track) return 62 this.audioTrack = track 63 if (track && this.hasAudioTarget) { 64 this.audioTarget.srcObject = new MediaStream([track]) 65 } else if (this.hasAudioTarget) { 66 this.audioTarget.srcObject = null 67 } 68 } 69 } 70 71 // Pin styling (position/size for the corner self-view) is driven by the 72 // `data-media-session-pinned-value` attribute via Tailwind variants in the template. 73 74 togglePin() { 75 this.pinnedValue = !this.pinnedValue 76 } 77 78 destroyTracks() { 79 if (this.hasVideoTarget) this.videoTarget.srcObject = null 80 if (this.hasBlurredVideoTarget) this.blurredVideoTarget.srcObject = null 81 if (this.hasScreenShareVideoTarget) this.screenShareVideoTarget.srcObject = null 82 if (this.hasAudioTarget) this.audioTarget.srcObject = null 83 this.videoTrack = null 84 this.screenShareTrack = null 85 this.audioTrack = null 86 } 87 88 destroy() { 89 this.destroyTracks() 90 this.element.remove() 91 } 92}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.