I am trying to play html5 video in a program that use webkitgtk and written in C.
In order to test the html5 video I set up a server with a webpage:
Your browser does not support the video tag.
and it works in firefox, but when I use my program to display that webpage, the vide doesn't work.
My C program:
#include
#include
static void destroyWindowCb(GtkWidget* widget, GtkWidget* window);
static gboolean closeWebViewCb(WebKitWebView* webView, GtkWidget* window);
int main(int argc, char* argv[])
{
// Initialize GTK+
gtk_init(&argc, &argv);
// Create an 800x600 window that will contain the browser instance
GtkWidget *main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_decorated(main_window, false);
gtk_window_move(main_window,0,0);
gtk_window_set_default_size(GTK_WINDOW(main_window), 800, 600);
// Create a browser instance
WebKitWebView *webView = WEBKIT_WEB_VIEW(webkit_web_view_new());
// Create a scrollable area, and put the browser instance into it
GtkWidget *scrolledWindow = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledWindow),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_container_add(GTK_CONTAINER(scrolledWindow), GTK_WIDGET(webView));
// Set up callbacks so that if either the main window or the browser instance is
// closed, the program will exit
g_signal_connect(main_window, "destroy", G_CALLBACK(destroyWindowCb), NULL);
g_signal_connect(webView, "close-web-view", G_CALLBACK(closeWebViewCb), main_window);
// Put the scrollable area into the main window
gtk_container_add(GTK_CONTAINER(main_window), scrolledWindow);
// Load a web page into the browser instance
webkit_web_view_load_uri(webView, "http://localhost/");
//webkit_web_view_load_uri(webView, "http://www.shastaherps.org/sampleHTML5.html#multimedia");
// Make sure that when the browser area becomes visible, it will get mouse
// and keyboard events
gtk_widget_grab_focus(GTK_WIDGET(webView));
// Make sure the main window and all its contents are visible
gtk_widget_show_all(main_window);
// Run the main GTK+ event loop
gtk_main();
return 0;
}
static void destroyWindowCb(GtkWidget* widget, GtkWidget* window)
{
gtk_main_quit();
}
static gboolean closeWebViewCb(WebKitWebView* webView, GtkWidget* window)
{
gtk_widget_destroy(window);
return TRUE;
}
Any sugestion?
Thanks.
P.D I install libwebkitgtk from Ubuntu repository.