You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This module doesn't detect a change in camera state. Here is an example program which polls the module every 1 second. While the program is running, if I start or stop using the camera, the output never reflects the new state. Terminating my program and starting it again does reflect the new state.
package main
import (
"log""time"
mediaDevices "github.com/antonfisher/go-media-devices-state"
)
funcmain() {
for {
isCameraOn, err:=mediaDevices.IsCameraOn()
iferr!=nil {
log.Println("Error:", err)
} else {
log.Println("Is camera on:", isCameraOn)
}
time.Sleep(1*time.Second)
}
}
The text was updated successfully, but these errors were encountered:
Yes, can confirm i see the same. Interesting that if i run it like:
while sleep 1; do go run ./cmd/demo.go; done;
it detects the camera properly. One workaround can be spawning a process for each check:
./cmd/demo.go:
package main
import (
"fmt""os/exec""time"
)
funcmain() {
for {
checkCmd:=exec.Command("bash", "-c", "go run /tmp/check.go")
checkOut, _:=checkCmd.Output()
fmt.Printf("Is camera on: %v", string(checkOut))
time.Sleep(1*time.Second)
}
}
This module doesn't detect a change in camera state. Here is an example program which polls the module every 1 second. While the program is running, if I start or stop using the camera, the output never reflects the new state. Terminating my program and starting it again does reflect the new state.
The text was updated successfully, but these errors were encountered: