Xfce Wiki

Sub domains
 

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
midori:webmedia_now-playing [2015/02/01 13:44] – [BIG THanks] jamesaxlmidori:webmedia_now-playing [2026/10/07 22:32] (current) – Delete obsolete page kevinbowen
Line 1: Line 1:
-====== Webmedia now-playing - Tutorial ====== 
- 
-**This document is licensed under the LGPL 2.1.** 
- 
-===== What is Webmedia now-playing ===== 
-Webmedia now-playing is a midori extension developed for using Dbus, this extension allow users to get the video title that midori play in youtube/ Vimeo/ Dailymention/Coup.\\ 
-In this Tuto We are going to show you how to use it :-). 
-===== Using Shell script ===== 
-Big thanks to [[https://github.com/meebey|meebey]] the owner of this script. 
-<code> 
-eval $(dbus-send --session --print-reply --dest=org.midori.mediaHerald /org/midori/mediaHerald org.freedesktop.DBus.Properties.GetAll string:"org.midori.mediaHerald" | awk ' 
-    /string  *"VideoTitle/{ 
-        while (1) { 
-            getline line 
-            if (line ~ /string "/) 
-                sub(/.*string /, "TITLE=", line) 
-                print line 
-                break 
-            } 
-        } 
-        /string  *"VideoUri/{ 
-        while (1) { 
-            getline line 
-            if (line ~ /string "/) 
-                sub(/.*string /, "URI=", line) 
-                print line 
-                break 
-            } 
-        } 
-    ') 
-echo "You are now playing: $VideoTitle - $VideoUri" 
-</code> 
-As you see **mediaHerald** is a Dbus service that our extension created to store video's title and uri.\\ 
-Let's do an example you should first open [[https://www.youtube.com/watch?v=O2cebaY5Wlc]] and run our shell script, the result is: 
-<code> 
-You are now playing:  - ‪Midori 0.5.8 : A Fast and Lightweight Web Browser For Linux Mint - YouTube 
-</code> 
-Enjoy baby :-D 
-===== Some examples ===== 
-**VALA** 
-<code> 
-[DBus (name = "org.midori.mediaHerald")] 
-interface Demo : Object { 
-    public abstract string video_title {owned get; owned set;} 
-    public abstract string video_uri {owned get; owned set;} 
-} 
- 
-void main () { 
-  try { 
-    Demo demo = Bus.get_proxy_sync (BusType.SESSION, "org.midori.mediaHerald", 
-                                    "/org/midori/mediaHerald"); 
- 
-    string title = demo.video_title; 
-    string uri = demo.video_uri; 
-    stdout.printf ("you are playing %s, follow me on %s\n", title, uri); 
- 
-  } catch (IOError e) { 
-    stderr.printf ("%s\n", e.message); 
-  } 
-} 
-</code> 
-**Result:**\\ 
-<code> 
-you are playing ‪Midori 0.5.8 : A Fast and Lightweight Web Browser For Linux Mint - YouTube, follow me on https://www.youtube.com/watch?v=O2cebaY5Wlc 
-</code> 
-**Python let's make it more short 8-)** 
-<code> 
-import dbus 
-bus = dbus.SessionBus() 
-service = bus.get_object('org.midori.mediaHerald','/org/midori/mediaHerald') 
-props_iface = dbus.Interface(service, 'org.freedesktop.DBus.Properties') 
-properties = props_iface.GetAll('org.midori.mediaHerald') 
-print "You are playing %s, follow me %s" %(properties.get("VideoTitle")[1:], properties.get("VideoUri")[0:]) 
-</code> 
-**Result:**\\ 
-<code> 
-You are playing Midori 0.5.8 : A Fast and Lightweight Web Browser For Linux Mint - YouTube, follow me https://www.youtube.com/watch?v=O2cebaY5Wlc 
-</code> 
-**C with Glib and Gio Headache Please LOL** 
-<code> 
-#include <glib.h> 
-#include <gio/gio.h> 
- 
-gchar* get_video_title(GDBusProxy *proxy) { 
- GVariant *_inner_reply; 
- _inner_reply = g_dbus_proxy_get_cached_property (proxy, "VideoTitle"); 
- gchar* _result; 
- if (!_inner_reply) { 
- GVariant *_arguments; 
- GVariant *_reply; 
- GVariantBuilder _arguments_builder; 
- g_variant_builder_init (&_arguments_builder, G_VARIANT_TYPE_TUPLE); 
- g_variant_builder_add_value (&_arguments_builder, g_variant_new_string ("org.midori.mediaHerald")); 
- g_variant_builder_add_value (&_arguments_builder, g_variant_new_string ("VideoTitle")); 
- _arguments = g_variant_builder_end (&_arguments_builder); 
- _reply = g_dbus_proxy_call_sync (proxy, "org.freedesktop.DBus.Properties.Get", _arguments, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL); 
- if (!_reply) { 
- return NULL; 
- } 
- g_variant_get (_reply, "(v)", &_inner_reply); 
- g_variant_unref (_reply); 
- } 
- _result = g_variant_dup_string (_inner_reply, NULL); 
- g_variant_unref (_inner_reply); 
- return _result; 
-  
-} 
- 
-gchar* get_video_uri(GDBusProxy *proxy) { 
- GVariant *_inner_reply; 
- _inner_reply = g_dbus_proxy_get_cached_property (proxy, "VideoUri"); 
- gchar* _result; 
- if (!_inner_reply) { 
- GVariant *_arguments; 
- GVariant *_reply; 
- GVariantBuilder _arguments_builder; 
- g_variant_builder_init (&_arguments_builder, G_VARIANT_TYPE_TUPLE); 
- g_variant_builder_add_value (&_arguments_builder, g_variant_new_string ("org.midori.mediaHerald")); 
- g_variant_builder_add_value (&_arguments_builder, g_variant_new_string ("VideoUri")); 
- _arguments = g_variant_builder_end (&_arguments_builder); 
- _reply = g_dbus_proxy_call_sync (proxy, "org.freedesktop.DBus.Properties.Get", _arguments, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL); 
- if (!_reply) { 
- return NULL; 
- } 
- g_variant_get (_reply, "(v)", &_inner_reply); 
- g_variant_unref (_reply); 
- } 
- _result = g_variant_dup_string (_inner_reply, NULL); 
- g_variant_unref (_inner_reply); 
- return _result; 
-} 
- 
- 
-int main(void) { 
- GError *error = NULL; 
- GDBusConnection *bus; 
- GDBusProxy *proxy; 
- bus = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &error); 
- if (!bus) { 
- g_warning("Failed to connect to session bus: %s", error->message); 
- g_error_free(error); 
- return 1; 
- } 
- proxy  = g_dbus_proxy_new_sync (bus, 
-                       G_DBUS_PROXY_FLAGS_NONE, 
-                       NULL, 
-                       "org.midori.mediaHerald", 
-                       "/org/midori/mediaHerald", 
-                       "org.freedesktop.DBus.Properties", 
-                       NULL, 
-                       &error); 
-    gchar* title = get_video_title(proxy); 
-    gchar* uri = get_video_uri(proxy); 
- g_printf("you are now watching  %s - %s\n", title, uri); 
- return 0; 
-} 
- 
-</code> 
- 
-MakeFile 
-<code> 
-pkg_packages := glib-2.0 gio-2.0 
-CC=gcc 
-PKG_CFLAGS  := $(shell pkg-config --cflags $(pkg_packages)) 
-PKG_LDFLAGS := $(shell pkg-config --libs $(pkg_packages)) 
- 
-CFLAGS  := $(PKG_CFLAGS) $(ADD_CFLAGS) $(CFLAGS) 
-LDFLAGS := $(PKG_LDFLAGS) $(LDFLAGS) 
- 
-targets = midori-example 
- 
-.PHONY: all clean 
-all: $(targets) 
- 
-dbus-example: midori-example.c 
- $(CC) $(CFLAGS) $< -o $@ $(LDFLAGS) 
- 
-clean: 
- $(RM) $(targets) 
-</code> 
- 
-**Result:**\\ 
-<code> 
-you are now watching  ‪Installing Linux on Tegra TK1 - http://coub.com/view/44obz 
-</code> 
- 
-====== BIG THanks ====== 
-**kalikiana **: The developer of MIDORI, code helper.\\ 
-**pfor**: Code helper.\\ 
-**A.R**(owner of the quote): Earth and all that is in it, with knowledge we protect it. And the best of mankind knowledge makes him and he makes it.