c++gtkmmwebkitgtk

Trouble Playing Youtube Videos with libwebkitgtk-4


Whenever I try to browse to a youtube video using the libwebkit2gtk library in Ubuntu 18 LTS, I'm met with a "Your browser can't play this video". I see that other browsers that use this library can play youtube content just fine (org.gnome.Epiphany).

Can someone point me in the right direction as to what I'm missing?

#include <webkit2/webkit2.h>
#include <gtkmm.h>

int main(int argc, char* argv[])
{
    Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "");
    Gtk::Window window;
    window.set_default_size(1280, 720);

    WebKitSettings* settings = webkit_settings_new();
    webkit_settings_set_enable_mediasource(settings, true);
    WebKitWebView* one = WEBKIT_WEB_VIEW(webkit_web_view_new_with_settings(settings));
    Gtk::Widget* three = Glib::wrap(GTK_WIDGET(one));
    window.add(*three);

    webkit_web_view_load_uri(one, "https://www.youtube.com/watch?v=RVnARGhhs9w");
    window.show_all();

    app->run(window);
    return 0;
}

Solution

  • It turns out that I needed the gstreamer1.0-libav package installed. After I install this through apt, my program started playing youtube videos with no issue.

    sudo apt install -y gstreamer1.0-libav