webkitGTK中webview打开HTML文件播放服务器上的视频需要什么插件
我自己开发了一个应用程序,需要给用户提供这样一个功能,打开一个html网址播放事先存放在服务器端的视频,这个视频是通过swf做到html中的,我需要哪些插件?我的webview 需要进行什么设置,才能播放视频?
我的工作环境:ubuntu 11.10, webkitGTK+,GTK+3.0,
我现在的问题是,视频播放的时候,只有声音,白屏,看不见视频。大家能告诉我这是为什么么?谢谢
下面是我的代码:
#include <gtk/gtk.h> #include <webkit/webkit.h> #define URI_PATH1 "http://10.1.58.230:/demos/SimplePlayer.html" int main(int argc, char* argv[]) { // Initialize GTK+ gtk_init(&argc, &argv); // Create an 800x600 window that will contain the browser instance GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_position (GTK_WINDOW (window),GTK_WIN_POS_CENTER_ALWAYS); gtk_window_set_default_size(GTK_WINDOW(window), 800, 600); gtk_container_set_border_width(GTK_CONTAINER(window),10); GtkWidget *vbox = gtk_vbox_new(FALSE,0); gtk_container_set_border_width(GTK_CONTAINER(vbox),10); gtk_container_add(GTK_CONTAINER(window),vbox); GtkWidget *box_view = gtk_vbox_new(TRUE,0); GtkWidget *hbox = gtk_hbox_new(FALSE,0); //创建提示关闭按钮 GtkWidget *button1 = gtk_button_new(); gtk_button_set_label(GTK_BUTTON(button1)," 关闭视频 "); g_signal_connect(G_OBJECT(button1),"clicked",G_CALLBACK(destroyWindowCb),NULL); GtkWidget *label1 = gtk_label_new(NULL); //字体为蓝色20号 gtk_label_set_markup(GTK_LABEL(label1),"<span foreground = 'blue' font_desc = '20'>关闭视频</span>"); //排列 gtk_box_pack_start(GTK_BOX(vbox),box_view, TRUE, TRUE, 5); gtk_box_pack_start(GTK_BOX(vbox),hbox,FALSE,FALSE,5); //hbox排列 gtk_box_pack_start(GTK_BOX(hbox),button1, FALSE, FALSE, 5); gtk_box_pack_start(GTK_BOX(hbox),label1, FALSE, FALSE, 5); // 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_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledWindow),GTK_SHADOW_IN); gtk_box_pack_start(GTK_BOX(box_view),scrolledWindow,TRUE,TRUE,0); // Create a browser instance WebKitWebView *webview = WEBKIT_WEB_VIEW(webkit_web_view_new()); 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(window, "destroy", G_CALLBACK(destroyWindowCb), NULL); g_signal_connect(webview, "close-web-view", G_CALLBACK(closewebviewCb), window); // Load a web page into the browser instance webkit_web_view_load_uri(webview,URI_PATH1); WebKitWebSettings *settings1 = webkit_web_settings_new (); g_object_set (G_OBJECT(settings1), "enable-plugins",TRUE, NULL); webkit_web_view_set_settings (WEBKIT_WEB_VIEW(webview), settings1); g_object_unref (settings1); //Default value:TURE WebKitWebSettings *settings2 = webkit_web_settings_new (); g_object_set (G_OBJECT(settings2), "enable-scripts", TRUE, NULL); webkit_web_view_set_settings (WEBKIT_WEB_VIEW(webview), settings2); g_object_unref (settings2); gtk_widget_grab_focus(GTK_WIDGET(webview)); // Make sure the main window and all its contents are visible gtk_widget_show_all(window); // Run the main GTK+ event loop gtk_main(); return 0; }
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我已经安装libflashplayer.so到以下目录中,但是播放的时候还是只有声音,没有视频,这是怎么回事?
/usr/lib/mozilla/plugins
/usr/share/mozilla/plugins
~/.mozilla/plugins
要flash插件
这是执行时候的效果图