Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

157
Views
Accessing video devices in Webkit2Gtk

I am trying to access my webcam from a Webkit2Gtk window, but I am unable to. I'm using the WebKit2 python module.

from gi.repository import Gtk
from gi.repository import WebKit2

class BrowserView:
    def __init__(self):
        window = Gtk.Window()
        window.connect('delete-event', Gtk.main_quit)

        context=WebKit2.WebContext()
        context.set_tls_errors_policy(WebKit2.TLSErrorsPolicy(0))
        
        self.view = WebKit2.WebView(web_context=context)

        self.view.connect("permission-request", WebKit2.PermissionRequest)
        self.settings = self.view.get_settings()
        self.settings.set_property("enable-mediasource", True)
        self.settings.set_property("enable-media-stream", True)

        window.add(self.view)
        self.view.load_uri('https://localhost:8080')

        window.show_all()

if __name__ == "__main__":
    BrowserView()
    Gtk.main()

The webpage is hosted with flask and using WebcamJS for a webcam interfacing library. The javascript is an example for using WebcamJS.

<script src="{{url_for('static',filename='webcam.js')}}"></script>

<div id="my_camera" style="width:320px; height:240px;"></div>
<div id="my_result"></div>

<script language="JavaScript">
    Webcam.attach( '#my_camera' );

    function take_snapshot() {
        Webcam.snap( function(data_uri) {
            document.getElementById('my_result').innerHTML = '<img src="'+data_uri+'"/>';
        } );
    }
</script>
<a href="javascript:void(take_snapshot())">Take Snapshot</a>

This webpage works fine in chrome but I get the error Webcam.js Error: No supported webcam when loading the page in Webkit2. SSL is enabled.

Has anyone been able to get webcams / external media devices to work in Webkit2GTK?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!