Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Gtk;
- using Gst;
- public class player_window : Window
- {
- private ToolButton open_button = new ToolButton.from_stock (Stock.OPEN);
- private ToolButton play_button = new ToolButton.from_stock (Stock.MEDIA_PLAY);
- private ToolButton pause_button = new ToolButton.from_stock (Stock.MEDIA_PAUSE);
- private DrawingArea drawing_area = new DrawingArea();
- private Box vbox = new Box(Orientation.VERTICAL, 2);
- private Box hbox = new Box(Orientation.HORIZONTAL, 3);
- dynamic Element playbin = ElementFactory.make ("playbin2", "playbin");
- Element sink = ElementFactory.make ("xvimagesink", "sink");
- public player_window()
- {
- title = "My Fiwst Pwogwam";
- hbox.pack_start(open_button, true, true, 0);
- hbox.pack_start(play_button, true, true, 0);
- hbox.pack_start(pause_button, true, true, 0);
- drawing_area.set_size_request(320, 240);
- vbox.pack_start(drawing_area, true, true, 0);
- vbox.pack_start(hbox, false, true, 0);
- add(vbox);
- play_button.clicked.connect(on_play);
- pause_button.clicked.connect(on_pause);
- open_button.clicked.connect(on_open);
- destroy.connect (Gtk.main_quit);
- }
- public void on_play()
- {
- playbin.video_sink = sink;
- sink.set("force-aspect-ratio", true);
- ((XOverlay) sink).set_xwindow_id (Gdk.X11Window.get_xid (drawing_area.get_window ()));
- playbin.set_state (State.PLAYING);
- }
- public void on_pause()
- {
- playbin.set_state (State.PAUSED);
- }
- public void on_open()
- {
- var file_chooser = new FileChooserDialog("Select media", this, FileChooserAction.OPEN, Stock.CANCEL, ResponseType.CANCEL, Stock.OPEN, ResponseType.ACCEPT, null);
- if (file_chooser.run() == ResponseType.ACCEPT)
- {
- playbin.set_state(State.READY);
- playbin.uri = file_chooser.get_uri();
- }
- file_chooser.destroy();
- }
- }
- public static int main(string[] args)
- {
- Gtk.init(ref args);
- Gst.init(ref args);
- var app = new player_window();
- app.show_all();
- Gtk.main();
- return 0;
- }
Add Comment
Please, Sign In to add comment