rotrevrep

gstreamer-player-1.0 sample

Dec 25th, 2015
583
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Vala 1.19 KB | None | 0 0
  1. public class Renderer : Gst.PlayerVideoRenderer, GLib.Object {
  2.     Gst.Element gtksink;
  3.    
  4.     construct {
  5.         gtksink = Gst.ElementFactory.make ("gtksink", null);
  6.     }
  7.    
  8.     public Gtk.Widget widget {
  9.         owned get {
  10.             Gtk.Widget w;
  11.             gtksink.get ("widget", out w);
  12.             return w;
  13.         }
  14.     }
  15.    
  16.     public Gst.Element create_video_sink (Gst.Player player) {
  17.         return gtksink;
  18.     }
  19. }
  20.  
  21. public static void main (string[] args) {
  22.     Gtk.init (ref args);
  23.     Gst.init (ref args);
  24.     var window = new Gtk.Window();
  25.     var renderer = new Renderer();
  26.     var player = new Gst.Player.full (renderer, null);
  27.     player.pipeline.bus.add_watch (0, (bus, msg) => {
  28.         if (msg.type == Gst.MessageType.TAG) {
  29.             Gst.TagList list;
  30.             msg.parse_tag (out list);
  31.             print ("%s\n\n", list.to_string());
  32.         }
  33.         return true;
  34.     });
  35.     window.add (renderer.widget);
  36.     player.state_changed.connect (state => {
  37.         /* always NULL
  38.         print ("%s\n", player.media_info.get_tags().to_string());
  39.         print ("%s\n", player.current_audio_track.get_tags().to_string());
  40.         print ("%s\n", player.current_video_track.get_tags().to_string());
  41.         */
  42.     });
  43.     player.uri = "https://www.youtube.com/watch?v=Il61bCC4g3w";
  44.     player.play();
  45.     window.show_all();
  46.     Gtk.main();
  47. }
Add Comment
Please, Sign In to add comment