public void LoadVideo(string uri)
        {
            if (gstThread != null)
            {
                isrunning = false;
                gstThread.Join();
                gstThread = new Thread(new ThreadStart(KeepPolling));
            }

            if (playBin != null)
            {
                playerState = VideoPlayerState.STOPPED;
                Console.WriteLine("STOPPED");

                //Dispose playbin2 and appsink
                playBin.SetState(State.Null);
                playBin.Dispose();
                appSink.SetState(State.Null);
                appSink.Dispose();

                //Create playbin2 and appsink
                playBin = new PlayBin2();

                appSink      = ElementFactory.Make("appsink", "sink") as AppSink;
                appSink.Caps = new Caps("video/x-raw-yuv", new object[] {});
                //appSink.Caps = new Caps("video/x-raw-rgb", new object[] { "bpp", 24 });
                appSink.Drop       = true;
                appSink.MaxBuffers = 8;
                playBin.VideoSink  = appSink;
            }
            else
            {
                //Create playbin2 and appsink
                playBin      = new PlayBin2();
                appSink      = ElementFactory.Make("appsink", "sink") as AppSink;
                appSink.Caps = new Caps("video/x-raw-yuv", new object[] {});
                //appSink.Caps = new Caps("video/x-raw-rgb", new object[] { "bpp", 24 });
                appSink.Drop       = true;
                appSink.MaxBuffers = 8;
                playBin.VideoSink  = appSink;
            }

            //init variables
            texturesOK = false;
            width      = 0;
            height     = 0;

            //Set file uri
            string validUri = uri;

            if (!validUri.StartsWith("file://"))
            {
                validUri = "file://" + uri;
            }
            playBin.Uri = validUri;
            StateChangeReturn sr = playBin.SetState(State.Playing);

            Console.WriteLine(sr.ToString());
            playerState = VideoPlayerState.LOADING;
            Console.WriteLine("LOADING:" + validUri);

            if (gstThread == null)
            {
                gstThread = new Thread(new ThreadStart(KeepPolling));
            }

            isrunning = true;
            //Start polling thread...future thought, using async queue?
            gstThread.Start();

            return;
        }
Ejemplo n.º 2
0
 public YascStreamingException(StateChangeReturn state) : base(string.Format("State change error: {0} ", state.ToString()))
 {
 }