Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| midori:webmedia_now-playing [2015/02/01 13:44] – [BIG THanks] jamesaxl | midori: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/ | ||
| - | In this Tuto We are going to show you how to use it :-). | ||
| - | ===== Using Shell script ===== | ||
| - | Big thanks to [[https:// | ||
| - | < | ||
| - | eval $(dbus-send --session --print-reply --dest=org.midori.mediaHerald / | ||
| - | / | ||
| - | while (1) { | ||
| - | getline line | ||
| - | if (line ~ /string "/) | ||
| - | sub(/ | ||
| - | print line | ||
| - | break | ||
| - | } | ||
| - | } | ||
| - | / | ||
| - | while (1) { | ||
| - | getline line | ||
| - | if (line ~ /string "/) | ||
| - | sub(/ | ||
| - | print line | ||
| - | break | ||
| - | } | ||
| - | } | ||
| - | ') | ||
| - | echo "You are now playing: $VideoTitle - $VideoUri" | ||
| - | </ | ||
| - | As you see **mediaHerald** is a Dbus service that our extension created to store video' | ||
| - | Let's do an example you should first open [[https:// | ||
| - | < | ||
| - | You are now playing: | ||
| - | </ | ||
| - | Enjoy baby :-D | ||
| - | ===== Some examples ===== | ||
| - | **VALA** | ||
| - | < | ||
| - | [DBus (name = " | ||
| - | 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, | ||
| - | "/ | ||
| - | |||
| - | 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 (" | ||
| - | } | ||
| - | } | ||
| - | </ | ||
| - | **Result: | ||
| - | < | ||
| - | you are playing Midori 0.5.8 : A Fast and Lightweight Web Browser For Linux Mint - YouTube, follow me on https:// | ||
| - | </ | ||
| - | **Python let's make it more short 8-)** | ||
| - | < | ||
| - | import dbus | ||
| - | bus = dbus.SessionBus() | ||
| - | service = bus.get_object(' | ||
| - | props_iface = dbus.Interface(service, | ||
| - | properties = props_iface.GetAll(' | ||
| - | print "You are playing %s, follow me %s" %(properties.get(" | ||
| - | </ | ||
| - | **Result: | ||
| - | < | ||
| - | You are playing Midori 0.5.8 : A Fast and Lightweight Web Browser For Linux Mint - YouTube, follow me https:// | ||
| - | </ | ||
| - | **C with Glib and Gio Headache Please LOL** | ||
| - | < | ||
| - | #include < | ||
| - | #include < | ||
| - | |||
| - | gchar* get_video_title(GDBusProxy *proxy) { | ||
| - | GVariant *_inner_reply; | ||
| - | _inner_reply = g_dbus_proxy_get_cached_property (proxy, " | ||
| - | gchar* _result; | ||
| - | if (!_inner_reply) { | ||
| - | GVariant *_arguments; | ||
| - | GVariant *_reply; | ||
| - | GVariantBuilder _arguments_builder; | ||
| - | g_variant_builder_init (& | ||
| - | g_variant_builder_add_value (& | ||
| - | g_variant_builder_add_value (& | ||
| - | _arguments = g_variant_builder_end (& | ||
| - | _reply = g_dbus_proxy_call_sync (proxy, " | ||
| - | if (!_reply) { | ||
| - | return NULL; | ||
| - | } | ||
| - | g_variant_get (_reply, " | ||
| - | g_variant_unref (_reply); | ||
| - | } | ||
| - | _result = g_variant_dup_string (_inner_reply, | ||
| - | 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, " | ||
| - | gchar* _result; | ||
| - | if (!_inner_reply) { | ||
| - | GVariant *_arguments; | ||
| - | GVariant *_reply; | ||
| - | GVariantBuilder _arguments_builder; | ||
| - | g_variant_builder_init (& | ||
| - | g_variant_builder_add_value (& | ||
| - | g_variant_builder_add_value (& | ||
| - | _arguments = g_variant_builder_end (& | ||
| - | _reply = g_dbus_proxy_call_sync (proxy, " | ||
| - | if (!_reply) { | ||
| - | return NULL; | ||
| - | } | ||
| - | g_variant_get (_reply, " | ||
| - | g_variant_unref (_reply); | ||
| - | } | ||
| - | _result = g_variant_dup_string (_inner_reply, | ||
| - | 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, | ||
| - | if (!bus) { | ||
| - | g_warning(" | ||
| - | g_error_free(error); | ||
| - | return 1; | ||
| - | } | ||
| - | proxy | ||
| - | | ||
| - | NULL, | ||
| - | " | ||
| - | "/ | ||
| - | " | ||
| - | NULL, | ||
| - | & | ||
| - | gchar* title = get_video_title(proxy); | ||
| - | gchar* uri = get_video_uri(proxy); | ||
| - | g_printf(" | ||
| - | return 0; | ||
| - | } | ||
| - | |||
| - | </ | ||
| - | |||
| - | MakeFile | ||
| - | < | ||
| - | pkg_packages := glib-2.0 gio-2.0 | ||
| - | CC=gcc | ||
| - | PKG_CFLAGS | ||
| - | PKG_LDFLAGS := $(shell pkg-config --libs $(pkg_packages)) | ||
| - | |||
| - | CFLAGS | ||
| - | LDFLAGS := $(PKG_LDFLAGS) $(LDFLAGS) | ||
| - | |||
| - | targets = midori-example | ||
| - | |||
| - | .PHONY: all clean | ||
| - | all: $(targets) | ||
| - | |||
| - | dbus-example: | ||
| - | $(CC) $(CFLAGS) $< -o $@ $(LDFLAGS) | ||
| - | |||
| - | clean: | ||
| - | $(RM) $(targets) | ||
| - | </ | ||
| - | |||
| - | **Result: | ||
| - | < | ||
| - | you are now watching | ||
| - | </ | ||
| - | |||
| - | ====== 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. | ||