Exemplo n.º 1
0
    void ButtonOpenClicked(object sender, EventArgs args)
    {
        FileChooserDialog dialog = new FileChooserDialog("Open", this, FileChooserAction.Open, new object[] { "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept });

        dialog.SetCurrentFolder(Environment.GetFolderPath(Environment.SpecialFolder.Personal));

        if (dialog.Run() == (int)ResponseType.Accept)
        {
            _pipelineOK = false;

            if (_pipeline != null)
            {
                _pipeline.SetState(Gst.State.Null);
                _pipeline.Dispose();
            }

            _scale.Value = 0;

            _pipeline = new Pipeline(string.Empty);

            Element     playbin = ElementFactory.Make("playbin", "playbin");
            XvImageSink sink    = XvImageSink.Make("sink");

            if (_pipeline == null)
            {
                Console.WriteLine("Unable to create pipeline");
            }
            if (playbin == null)
            {
                Console.WriteLine("Unable to create element 'playbin'");
            }
            if (sink == null)
            {
                Console.WriteLine("Unable to create element 'sink'");
            }

            _pipeline.Add(playbin);

            XOverlayAdapter sinkadapter = new XOverlayAdapter(sink);
            sinkadapter.XwindowId = gdk_x11_drawable_get_xid(_da.GdkWindow.Handle);

            playbin.SetProperty("video-sink", sink);
            playbin.SetProperty("uri", "file://" + dialog.Filename);

            StateChangeReturn sret = _pipeline.SetState(Gst.State.Playing);

            if (sret == StateChangeReturn.Async)
            {
                State state, pending;
                sret = _pipeline.GetState(out state, out pending, Clock.Second * 5);
            }

            if (sret == StateChangeReturn.Success)
            {
                _pipelineOK = true;
            }
            else
            {
                Console.WriteLine("State change failed for {0} ({1})\n", dialog.Filename, sret);
            }
        }

        dialog.Destroy();
    }
Exemplo n.º 2
0
    void ButtonOpenClicked(object sender, EventArgs args)
    {
        FileChooserDialog dialog = new FileChooserDialog ("Open", this, FileChooserAction.Open, new object[] { "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept });
        dialog.SetCurrentFolder (Environment.GetFolderPath (Environment.SpecialFolder.Personal));

        if (dialog.Run () == (int)ResponseType.Accept)
        {
            _pipelineOK = false;

            if (_pipeline != null)
            {
                _pipeline.SetState (Gst.State.Null);
                _pipeline.Dispose ();
            }

            _scale.Value = 0;

            _pipeline = new Pipeline (string.Empty);

            Element playbin = ElementFactory.Make ("playbin", "playbin");
            XvImageSink sink = XvImageSink.Make ("sink");

            if (_pipeline == null)
                Console.WriteLine ("Unable to create pipeline");
            if (playbin == null)
                Console.WriteLine ("Unable to create element 'playbin'");
            if (sink == null)
                Console.WriteLine ("Unable to create element 'sink'");

            _pipeline.Add (playbin);

            XOverlayAdapter sinkadapter = new XOverlayAdapter (sink);
            sinkadapter.XwindowId = gdk_x11_drawable_get_xid (_da.GdkWindow.Handle);

            playbin.SetProperty ("video-sink", sink);
            playbin.SetProperty ("uri", "file://" + dialog.Filename);

            StateChangeReturn sret = _pipeline.SetState (Gst.State.Playing);

            if (sret == StateChangeReturn.Async)
            {
                State state, pending;
                sret = _pipeline.GetState (out state, out pending, Clock.Second * 5);
            }

            if (sret == StateChangeReturn.Success)
                _pipelineOK = true;
            else
                Console.WriteLine ("State change failed for {0} ({1})\n", dialog.Filename, sret);
        }

        dialog.Destroy ();
    }