c webkit支持html5,c - Play html5 video with WebKitGTK - Stack Overflow

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值