sindresorhus / Plash

💦 Make any website your Mac desktop wallpaper
https://sindresorhus.com/plash
MIT License
3.46k stars 128 forks source link

Webcam input #125

Open wednesdayayay opened 1 year ago

wednesdayayay commented 1 year ago

Is your feature request related to a problem? Please describe.

Websites that use your webcam don't seem to be able to pull the webcam feed at least on Ventura 13.2.1. Screen sharing also doesn't seem to work.

Describe the solution you'd like

I'd love to see the ability to directly set your webcam as the background and select which webcam you are using. If that can't happen The ability to use websites which pull your webcam feed. Usually I am asked for permission to use the camera but that popup doesn't show up when using plash.

Describe alternatives you've considered

I went into safari preferences and changed it to allow on cameras and also went to system preferences and allowed camera without asking. I've tried 4 or 5 different webcam testing websites and http://vdo.ninja but none of them show the camera.

Additional context

I have a video synthesis setup that uses software and hardware. I want to be able to choose one of the webcam feeds from the video system and set it as the background and then use a lightweight media viewer to layer things on top of the webcam. https://www.instagram.com/p/CpnqaenjAK4/ here is an example of what I'm doing but without the webcam feed as background.

dotzenith commented 1 year ago

Coming here with the same request, I think it would be a rather nice addition to the app.

willrogers007 commented 1 year ago

Diving deeper into the issue:

When I go into the console, it appears that window.navigator.mediaDevices is undefined - hence the lack of being able to pull from a webcam.

+1; I want this too!

I was about to make a page where I could have my camera video feed showing in the background, somewhat transparent, in a corner, similar to a part of The Mother of All Demos

willrogers007 commented 1 year ago

Got it to work by editing the project on XCode

This is a rudimentary fix that simply connects the technical components necessary to make this happen. Practically speaking, this is the first XCode project I've ever edited, so Sindre: I'm sure you know a better spot to put the following code snippet. That said, here's what I did following the article Developer: Requesting Authorization for Media Capture on macOS.

At the beginning of AppState › init()

switch AVCaptureDevice.authorizationStatus(for: .video) {
    case .authorized: // The user has previously granted access to the camera.
        // disabled because I have no idea what I'm doing (+ added a return)
        // self.setupCaptureSession()
        return

    case .notDetermined: // The user has not yet been asked for camera access.
        AVCaptureDevice.requestAccess(for: .video) { granted in
            if granted {
                // disabled because I have no idea what I'm doing:
                // self.setupCaptureSession()
            }
        }

    case .denied: // The user has previously denied access.
        return

    case .restricted: // The user can't grant access due to restrictions.
        return
}

CleanShot 2023-08-22 at 14 41 57@2x

CleanShot 2023-08-22 at 14 40 54@2x

Some considerations for Sindre

Users might not be expecting to be prompted unnecessarily for camera/microphone access, so it might be good to have this as something the user can opt into in the settings menu. I (tentatively) believe that it prompts for hardware access upon initial run of the Plash app, and additionally it made another UI permission request when my web page reached for navigator.mediaDevices.getUserMedia({ video: true }).

johncoles commented 9 months ago

I will take a look at a custom version using Xcode but it would be nice to have this as an option in the app Settings. I have a USB capture card connected to a Mac Mini I use as a status monitor in my office and the capture card has HDMI video going in to it (such as TV, CCTV cameras etc).