Skip to content

Commit ca03df9

Browse files
committed
WIP: Activate webcam
1 parent 5148c3d commit ca03df9

2 files changed

Lines changed: 60 additions & 1 deletion

File tree

cmd/run.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ var runCmd = &cobra.Command{
6060
meetingImpl.FillBotName("clockwise-bot")
6161
meetingImpl.JoinMeeting()
6262
// FIXME: Deactivated until ffmpeg vcam gets implemented
63-
// meetingImpl.ActivateVirtualWebcam("")
63+
meetingImpl.ActivateVirtualWebcam("")
6464

6565
err = meetingImpl.GetParticipants(1, &data)
6666
if err != nil {

internal/scrape/jitsi.go

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,65 @@ func (j *Jitsi) JoinMeeting() error {
7474
}
7575

7676
func (j *Jitsi) ActivateVirtualWebcam(camName string) error {
77+
fmt.Print("Locating camera activation button")
78+
// Locate camera activation button
79+
j.page.WaitForSelector("#new-toolbox > div > div > div > div.video-preview > div > div.toolbox-button")
80+
res, err := j.page.QuerySelector("#new-toolbox > div > div > div > div.video-preview > div > div.toolbox-button")
81+
if err != nil {
82+
return err
83+
}
84+
85+
fmt.Print("Check if camera is activated")
86+
// Check if camera is activated
87+
button_state, err := res.GetAttribute("aria-pressed")
88+
if err != nil {
89+
return err
90+
}
91+
92+
fmt.Print("Camera activation button: ", button_state)
93+
// If button is not pressed, press it
94+
if button_state == "true" {
95+
fmt.Print("Clicking on camera activation")
96+
err = res.Click()
97+
if err != nil {
98+
return err
99+
}
100+
}
101+
102+
fmt.Print("Check for video details (exposing available webcams)")
103+
// Check for video details (exposing available webcams)
104+
j.page.WaitForSelector("#video-settings-button")
105+
res, err = j.page.QuerySelector("#video-settings-button")
106+
if err != nil {
107+
return err
108+
}
109+
110+
// Check if video settings (list of webcams) is expanded already
111+
fmt.Print("Check if video settings (list of webcams) is expanded already")
112+
button_state, err = res.GetAttribute("aria-expanded")
113+
if err != nil {
114+
return err
115+
}
116+
117+
fmt.Print("Camera settings button: ", button_state)
118+
if button_state == "false" {
119+
fmt.Print("Clicking on expand settings")
120+
err = res.Click()
121+
if err != nil {
122+
return err
123+
}
124+
}
125+
126+
fmt.Print("Grabbing Video Settings dialog")
127+
j.page.WaitForSelector("#video-settings-dialog")
128+
res, err = j.page.QuerySelector("#video-settings-dialog")
129+
if err != nil {
130+
return err
131+
}
132+
133+
fmt.Print("Printing inner html")
134+
fmt.Print(res.InnerHTML())
135+
77136
return nil
78137
}
79138

0 commit comments

Comments
 (0)