0

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;
}
ThomasMalloch13
  • 103
  • 1
  • 5
  • Bets are you're not set up to handle the Encrypted Media Extensions request from the page. Or they could just be blacklisting browsers they don't know. Both are likely. – Mgetz Aug 16 '21 at 17:39
  • I've also tried enabling the encrypted media settings through webkit_settings_set_enable_encrypted_media() and changing the user agent in a similar way. Still no dice. – ThomasMalloch13 Aug 16 '21 at 18:05

1 Answers1

0

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

ThomasMalloch13
  • 103
  • 1
  • 5