using Gst; Element pipeline; // callback function for events on the pipeline // quits on error, stops playback on end of file bool on_bus_callback (Bus bus, Message message) { if (message.type == MessageType.ERROR) { print ("Error...\n"); GLib.Process.exit (1); } else if (message.type == MessageType.EOS) { print ("End of file...\n"); pipeline.set_state (State.NULL); } return true; } void main (string[] args) { // testing args if (args.length == 2) { print ("Now playing: " + args[1]); } else { print ("Usage : gstreamer-test file:///C:/path/file.mp3 \n"); GLib.Process.exit (0); } // initializing GStreamer Gst.init (ref args); // creating elements pipeline = ElementFactory.make ("playbin", "player"); pipeline.set ("uri", args[1]); // adding a callback for pipeline events var bus = pipeline.get_bus (); bus.add_watch (GLib.Priority.DEFAULT, on_bus_callback); // set pipeline state to PLAYING pipeline.set_state (State.PLAYING); // running main loop print ("\nRunning...\n"); new MainLoop ().run (); }