Exemple #1
0
        public async Task PlayAudioTemple(AirShowDataDto data, bool ForcePlay = false)
        {
            #region 判断是否为自动广播
            var p = SettingManager.GetSettingValue(AppSettings.General.PlayWay);
            if (!string.IsNullOrEmpty(p) && p == "2" && !ForcePlay)
            {
                Logger.Debug("此时为人工播放!");
                return;
            }
            #endregion

            #region 拼接语音片
            var list = CommAudioTempleInner(data);
            if (list == null || list.Count == 0)
            {
                return;
            }
            #endregion

            var code    = GetCode(data);
            var playSet = paySetRepository.FirstOrDefault(x => x.Code == code);
            if (playSet.AutoPlay || ForcePlay)
            {
                string devices = "";
                string port    = "00000000";
                playSet.AudioDevices.ForEach(x =>
                {
                    devices = x.Name;
                });

                if (data.FlightType == "I") //国际航班
                {
                    playSet.EnTopPwrPorts.ForEach(x =>
                    {
                        var index = int.Parse(x.Code);
                        port      = port.Substring(0, index - 1) + "1" + port.Substring(index);
                    });
                }
                else  //D 国内,Q 地区
                {
                    playSet.CnTopPwrPorts.ForEach(x =>
                    {
                        var index = int.Parse(x.Code);
                        port      = port.Substring(0, index - 1) + "1" + port.Substring(index);
                    });
                }



                if (list != null && list.Count > 0)
                {
                    list.ForEach(x =>
                    {
                        x.PlayStatus  = PlayStatus.等待播放;
                        x.PlayPort    = port;
                        x.WaitForPlay = DateTime.Now;
                        if (ForcePlay)
                        {
                            _wavCombine.Art_Player(x.FileName, devices, port);
                        }
                        else
                        {
                            _wavCombine.Player(x.FileName, devices, port);
                        }
                    });
                }
            }
        }