Пример #1
0
        public bool UpdateTemplate(int channel, int layer, string xmlStr, int flags)
        {
            if (caspar_ == null || !caspar_.IsConnected)
            {
                return(false);
            }

            lock (this._lockServer)
            {
                var layerLoad = layer * 2;
                var layerMain = layerLoad + 1;

                CGLayer cglayer = null;

                if (flags > 0)
                {
                    cglayer = layers.Where(o => o.Layer == layerMain).FirstOrDefault();
                }
                else
                {
                    cglayer = layers.Where(o => o.Layer == layerLoad).FirstOrDefault();
                }

                if (cglayer != null)
                {
                    if (cglayer.Type == CGType.Template)
                    {
                        try
                        {
                            CGComponentCollection components = new CGComponentCollection();
                            if (flags > 0)
                            {
                                components.AddComponent("Append", "1");
                            }
                            components.AddComponent("text", xmlStr);
                            casparRetrieved = false;
                            caspar_.Channels[channel].CG.Update(cglayer.Layer, 1, toStandarXml(xmlStr));
                            for (int time = 0; !casparRetrieved && caspar_.IsConnected && time < timeOut_; time += 100)
                            {
                                Thread.Sleep(100);
                            }
                            if (casparRetrieved)
                            {
                                return(true);
                            }
                        }
                        catch { }
                    }
                }
                return(false);
            }
        }
Пример #2
0
        public bool UpdateField(int channel, int layer, string fieldId, string value, int flags)
        {
            if (caspar_ == null || !caspar_.IsConnected)
            {
                return(false);
            }

            lock (this._lockServer)
            {
                var layerLoad = layer * 2;
                var layerMain = layerLoad + 1;

                CGLayer cglayer = null;

                if (flags > 0)
                {
                    cglayer = layers.Where(o => o.Layer == layerMain).FirstOrDefault();
                }
                else
                {
                    cglayer = layers.Where(o => o.Layer == layerLoad).FirstOrDefault();
                }

                if (cglayer != null)
                {
                    if (cglayer.Type == CGType.Template)
                    {
                        try
                        {
                            CGComponentCollection components = new CGComponentCollection();
                            if (flags > 0)
                            {
                                components.AddComponent("Append", "1");
                            }
                            components.AddComponent(fieldId, value);
                            casparRetrieved = false;
                            caspar_.Channels[channel].CG.Update(cglayer.Layer, 1, components);
                            for (int time = 0; !casparRetrieved && caspar_.IsConnected && time < timeOut_; time += 100)
                            {
                                Thread.Sleep(100);
                            }
                            if (casparRetrieved)
                            {
                                return(true);
                            }
                        }
                        catch { }
                    }
                    else
                    {
                        try
                        {
                            if (fieldId.ToLower() == "videopath")
                            {
                                casparLoadBGOK = false;
                                caspar_.Channels[channel].LoadBG(cglayer.Layer, value, false);
                                for (int time = 0; !casparLoadBGOK && caspar_.IsConnected && time < timeOut_; time += 100)
                                {
                                    Thread.Sleep(100);
                                }
                                if (casparLoadBGOK)
                                {
                                    return(true);
                                }
                            }
                            else
                            {
                                return(true);
                            }
                        }
                        catch { }
                    }
                }

                return(false);
            }
        }
Пример #3
0
        public bool FadeDown(int channel, int layer, int duration)
        {
            if (caspar_ == null || !caspar_.IsConnected)
            {
                return(false);
            }

            lock (this._lockServer)
            {
                var layerLoad = layer * 2;
                var layerMain = layerLoad + 1;

                var cglayer = layers.Where(o => o.Layer == layerMain).FirstOrDefault();

                if (cglayer != null)
                {
                    if (cglayer.Type == CGType.Template)
                    {
                        try
                        {
                            CGComponentCollection components = new CGComponentCollection();
                            components.AddComponent("FadeDown", duration.ToString());
                            casparRetrieved = false;
                            caspar_.Channels[channel].CG.Update(layerMain, 1, components);
                            for (int time = 0; !casparRetrieved && caspar_.IsConnected && time < timeOut_; time += 100)
                            {
                                Thread.Sleep(100);
                            }
                            if (casparRetrieved)
                            {
                                casparRetrieved = false;
                                caspar_.Channels[channel].CG.Invoke(layerMain, 1, "fadeDown");
                                for (int time = 0; !casparRetrieved && caspar_.IsConnected && time < timeOut_; time += 100)
                                {
                                    Thread.Sleep(100);
                                }
                                if (casparRetrieved)
                                {
                                    caspar_.Channels[channel].SetVolume(layerMain, 0, duration / 40, Easing.None);
                                    caspar_.Channels[channel].SetVolume(layerMain, 0, duration / 40, Easing.None);
                                    return(true);
                                }
                            }
                        }
                        catch { }
                    }
                    else
                    {
                        try
                        {
                            casparMixerOK = false;
                            caspar_.Channels[channel].SetOpacity(layerMain, 0, duration / 40, Easing.None);
                            for (int time = 0; !casparMixerOK && caspar_.IsConnected && time < timeOut_; timeOut_ += 100)
                            {
                                Thread.Sleep(100);
                            }
                            if (casparMixerOK)
                            {
                                caspar_.Channels[channel].SetVolume(layerMain, 0, duration / 40, Easing.None);
                                caspar_.Channels[channel].SetVolume(layerMain, 0, duration / 40, Easing.None);
                                return(true);
                            }
                        }
                        catch { }
                    }
                }

                return(false);
            }
        }
Пример #4
0
        public bool FadeUp(int channel, int layer, int duration, string xmlStr)
        {
            if (caspar_ == null || !caspar_.IsConnected)
            {
                return(false);
            }

            lock (this._lockServer)
            {
                var layerLoad = layer * 2;
                var layerMain = layerLoad + 1;

                var cglayer = layers.Where(o => o.Layer == layerLoad).FirstOrDefault();

                if (cglayer != null)
                {
                    caspar_.Channels[channel].Clear(layerMain);
                    var cglayerOld = layers.Where(o => o.Layer == layerMain).FirstOrDefault();
                    if (cglayerOld != null)
                    {
                        layers.Remove(cglayerOld);
                    }
                    caspar_.Channels[channel].SetOpacity(layerMain, 0, 0, Easing.None);
                    caspar_.Channels[channel].SetVolume(layerMain, 0, 0, Easing.None);

                    bool fadeOk = false;

                    if (cglayer.Type == CGType.Template)
                    {
                        try
                        {
                            CGComponentCollection components = new CGComponentCollection();
                            components.AddComponent("FadeUp", duration.ToString());
                            casparRetrieved = false;
                            caspar_.Channels[channel].CG.Update(layerLoad, 1, toStandarXml(xmlStr));
                            for (int time = 0; !casparRetrieved && caspar_.IsConnected && time < timeOut_; time += 100)
                            {
                                Thread.Sleep(100);
                            }
                            if (casparRetrieved)
                            {
                                casparRetrieved = false;
                                caspar_.Channels[channel].CG.Invoke(layerLoad, 1, "fadeUp");
                                for (int time = 0; !casparRetrieved && caspar_.IsConnected && time < timeOut_; time += 100)
                                {
                                    Thread.Sleep(100);
                                }
                                if (casparRetrieved)
                                {
                                    fadeOk = true;
                                }
                            }
                        }
                        catch { }
                    }
                    else
                    {
                        try
                        {
                            casparPlayed = false;
                            caspar_.Channels[channel].Play(layerLoad);
                            for (int time = 0; !casparPlayed && caspar_.IsConnected && time < timeOut_; timeOut_ += 100)
                            {
                                Thread.Sleep(100);
                            }
                            if (casparPlayed)
                            {
                                fadeOk = true;
                            }
                        }
                        catch { }
                    }

                    if (fadeOk)
                    {
                        var channelID = caspar_.Channels[channel].ID;
                        casparSwapOK = false;
                        caspar_.SendString("SWAP " + channelID + "-" + layerLoad + " " + channelID + "-" + layerMain);
                        for (int time = 0; !casparSwapOK && caspar_.IsConnected && time < timeOut_; timeOut_ += 100)
                        {
                            Thread.Sleep(100);
                        }
                        if (casparSwapOK)
                        {
                            if (cglayer.Type == CGType.Template)
                            {
                                caspar_.Channels[channel].SetOpacity(layerMain, 1, 0, Easing.None);
                            }
                            else
                            {
                                caspar_.Channels[channel].SetOpacity(layerMain, 1, duration / 40, Easing.None);
                            }
                            caspar_.Channels[channel].SetVolume(layerMain, 1, duration / 40, Easing.None);
                            caspar_.Channels[channel].SetVolume(layerMain, 1, duration / 40, Easing.None);

                            cglayer.Layer = layerMain;
                            caspar_.Channels[channel].Clear(layerLoad);
                            return(true);
                        }
                    }
                }

                return(false);
            }
        }