Example #1
0
        //private bool first = true;
        //VlcPlayer vlc = null;

        #region Evaluate
        public void Evaluate(int SpreadMax)
        {
            for (int i = 0; i < SpreadMax; i++)
            {
                string path;
                this.FPinInPath.GetString(i, out path);

                //Check for update here, if path has not changed leave the file on
                bool needreset = false;
                bool add       = false;
                if (this.players.Count < SpreadMax)
                {
                    //New player, need to create
                    needreset = true;
                    add       = true;
                }
                else
                {
                    if (this.players[i] != null)
                    {
                        if (path != this.players[i].FileName)
                        {
                            this.players[i].Stop();
                            this.players[i].Dispose();
                            //this.players[i].DestroyDevice();
                            needreset = true;
                        }
                    }
                    else
                    {
                        needreset = true;
                    }
                }

                if (needreset)
                {
                    if (File.Exists(path))
                    {
                        if (add)
                        {
                            this.players.Add(new VlcPlayer());
                        }
                        else
                        {
                            this.players[i] = new VlcPlayer();
                        }

                        this.players[i].SetFileName(path);

                        /*if (this.players[i].IsValid)
                         * {
                         *  this.players[i].Start();
                         * }*/
                    }
                    else
                    {
                        if (add)
                        {
                            this.players.Add(null);
                        }
                        else
                        {
                            //Just set a null here
                            this.players[i] = null;
                        }
                    }
                }
            }

            if (this.players.Count > SpreadMax)
            {
                for (int i = SpreadMax; i < this.players.Count; i++)
                {
                    this.players[i].Stop();
                    this.players[i].Dispose();
                }
                this.players.RemoveRange(SpreadMax, this.players.Count - SpreadMax);
            }

            this.FTextureOut.SliceCount = SpreadMax;

            //Now we can set all play/loop/seek stuff
            for (int i = 0; i < SpreadMax; i++)
            {
                if (this.players[i] != null)
                {
                    if (this.players[i].IsValid)
                    {
                        double dbldoseek;
                        this.FPinInDoSeek.GetValue(i, out dbldoseek);

                        if (dbldoseek > 0.5)
                        {
                            double seekpos;
                            this.FPinInSeekPos.GetValue(i, out seekpos);

                            //Seek in milliseconds
                            this.players[i].SetPosition(Convert.ToSingle(seekpos));
                        }

                        double dblstart;
                        this.FPinInStart.GetValue(0, out dblstart);
                        if (dblstart > 0.5)
                        {
                            this.players[i].SetPosition(0.0f);
                        }

                        double dblplay, dblloop, dblspeed, dblvolume;
                        this.FPinInPlay.GetValue(i, out dblplay);
                        this.FPinInLoop.GetValue(i, out dblloop);
                        this.FPinInSpeed.GetValue(i, out dblspeed);
                        this.FPinInVolume.GetValue(i, out dblvolume);

                        this.players[i].Play = dblplay > 0.5;

                        this.players[i].Loop = dblloop > 0.5;
                        this.players[i].SetSpeed((float)dblspeed);
                        this.players[i].SetVolume((float)dblvolume);
                    }
                }

                if (this.FTextureOut[i] == null)
                {
                    this.FTextureOut[i] = new DX11Resource <DX11DynamicTexture2D>();
                }
            }

            //Process all outputs
            this.FPinOutPosition.SliceCount = this.players.Count;
            this.FPinOutFPS.SliceCount      = this.players.Count;
            this.FPinOutDuration.SliceCount = this.players.Count;
            this.FPinOutValid.SliceCount    = this.players.Count;
            this.FSizeOut.SliceCount        = this.players.Count * 2;

            for (int i = 0; i < SpreadMax; i++)
            {
                if (this.players[i] != null)
                {
                    if (this.players[i].IsValid)
                    {
                        VlcPlayer v = this.players[i];
                        v.GetStatus();
                        this.FPinOutFPS.SetValue(i, v.Fps);
                        this.FPinOutDuration.SetValue(i, v.Duration);
                        this.FPinOutPosition.SetValue(i, v.Position);
                        this.FPinOutValid.SetValue(i, Convert.ToDouble(v.IsValid));
                        this.FSizeOut[i * 2]     = v.Width;
                        this.FSizeOut[i * 2 + 1] = v.Height;
                    }
                    else
                    {
                        this.FPinOutFPS.SetValue(i, -1);
                        this.FPinOutDuration.SetValue(i, -1);
                        this.FPinOutPosition.SetValue(i, -1);
                        this.FPinOutValid.SetValue(i, -1);
                        this.FSizeOut[i * 2]     = -1;
                        this.FSizeOut[i * 2 + 1] = -1;
                    }
                }
                else
                {
                    this.FPinOutFPS.SetValue(i, 0);
                    this.FPinOutDuration.SetValue(i, 0);
                    this.FPinOutPosition.SetValue(i, 0);
                    this.FPinOutValid.SetValue(i, 0);
                    this.FSizeOut[i * 2]     = -1;
                    this.FSizeOut[i * 2 + 1] = -1;
                }
            }
        }