17
mai
2013
[Javascript] Lire une vidéo avec gjs
mai
2013
Un article de Rachel
Pas de commentaires
voici un autre exemple d’utilisation de Gjs, une vidéo qui s’affiche dans une fenêtre Gtk :
const Gst = imports.gi.Gst;
const GLib = imports.gi.GLib;
const Gtk = imports.gi.Gtk;
const GstVideo = imports.gi.GstVideo;
const GdkX11 = imports.gi.GdkX11;
// Initialize gst
Gst.init(null,0);
Gtk.init(null);
let e = Gst.ElementFactory.make("playbin","playbin");
let win = new Gtk.Window({ type: Gtk.WindowType.TOPLEVEL });
e.uri = "file://u/r/l.avi";
let bus = e.get_bus();
bus.add_watch(0,function(b,m){
if(GstVideo.is_video_overlay_prepare_window_handle_message(m)){
m.src.set_window_handle(win.get_window().get_xid());
}
return true;
});
e.set_state(Gst.State.PLAYING);
win.show();
win.connect("delete-event",function(widget){
Gtk.main_quit();
});
Gtk.main();
const GLib = imports.gi.GLib;
const Gtk = imports.gi.Gtk;
const GstVideo = imports.gi.GstVideo;
const GdkX11 = imports.gi.GdkX11;
// Initialize gst
Gst.init(null,0);
Gtk.init(null);
let e = Gst.ElementFactory.make("playbin","playbin");
let win = new Gtk.Window({ type: Gtk.WindowType.TOPLEVEL });
e.uri = "file://u/r/l.avi";
let bus = e.get_bus();
bus.add_watch(0,function(b,m){
if(GstVideo.is_video_overlay_prepare_window_handle_message(m)){
m.src.set_window_handle(win.get_window().get_xid());
}
return true;
});
e.set_state(Gst.State.PLAYING);
win.show();
win.connect("delete-event",function(widget){
Gtk.main_quit();
});
Gtk.main();