コード例 #1
0
ファイル: Conference.cs プロジェクト: seun104/AgbaraVOIP
        private List<string> _prepare_moh(FSOutbound outboundClient)
        {
            List<string> sound_files = new List<string>(); //[]
            if (!Util.IsUrlExist(moh_sound))
            {
                DirectoryInfo file = new DirectoryInfo(moh_sound);
                if (Util.IsFileExist(moh_sound))
                {
                    moh_sound = string.Format("file_string://{0}", moh_sound);
                    sound_files.Add(moh_sound);
                }
            }
            else
            {

                XElement doc = null;
                if (!string.IsNullOrEmpty(moh_sound))
                {
                    try
                    {
                        string response = outboundClient.SendToUrl(moh_sound, outboundClient.session_params, method);
                        doc = XElement.Parse(response);
                    }
                    catch (Exception ex)
                    {
                    }
                    if (doc.Name != "Response")
                        return sound_files;

                    // build play string from remote restxml
                    foreach (XElement element in doc.Elements())
                    {
                        //Play element
                        if (element.Name == "Play")
                        {
                            Play child = new Play();
                            child.ParseElement(element);
                            string sound_file = child.SoundFilePath;
                            if (!string.IsNullOrEmpty(sound_file))
                            {
                                int loop = child.LoopTimes;
                                if (loop == 0)
                                    loop = MAX_LOOPS;  //Add a high number to Play infinitely
                                //Play the file loop number of times
                                for (int i = 0; i < loop; i++)
                                {
                                    sound_files.Add(sound_file);
                                }
                                // Infinite Loop, so ignore other children
                                if (loop == MAX_LOOPS)
                                    break;
                            }
                        }
                        //Say element
                        else if (element.Name == "Say")
                        {
                            Say child = new Say();
                            child.ParseElement(element);
                           // child.Execute(outboundClient);
                            //sound_files.Add(pause_str);
                        }

                         //Redirect element
                        else if (element.Name == "Redirect")
                        {
                            Redirect child = new Redirect();
                            child.ParseElement(element);
                            child.Execute(outboundClient);
                        }
                    }
                }
            }
            return sound_files;
        }
コード例 #2
0
ファイル: Conference.cs プロジェクト: lichien2017/AgbaraVOIP
        private List <string> _prepare_moh(FSOutbound outboundClient)
        {
            List <string> sound_files = new List <string>(); //[]

            if (!Util.IsUrlExist(moh_sound))
            {
                DirectoryInfo file = new DirectoryInfo(moh_sound);
                if (Util.IsFileExist(moh_sound))
                {
                    moh_sound = string.Format("file_string://{0}", moh_sound);
                    sound_files.Add(moh_sound);
                }
            }
            else
            {
                XElement doc = null;
                if (!string.IsNullOrEmpty(moh_sound))
                {
                    try
                    {
                        string response = outboundClient.SendToUrl(moh_sound, outboundClient.session_params, method);
                        doc = XElement.Parse(response);
                    }
                    catch (Exception ex)
                    {
                    }
                    if (doc.Name != "Response")
                    {
                        return(sound_files);
                    }

                    // build play string from remote restxml
                    foreach (XElement element in doc.Elements())
                    {
                        //Play element
                        if (element.Name == "Play")
                        {
                            Play child = new Play();
                            child.ParseElement(element);
                            string sound_file = child.SoundFilePath;
                            if (!string.IsNullOrEmpty(sound_file))
                            {
                                int loop = child.LoopTimes;
                                if (loop == 0)
                                {
                                    loop = MAX_LOOPS;  //Add a high number to Play infinitely
                                }
                                //Play the file loop number of times
                                for (int i = 0; i < loop; i++)
                                {
                                    sound_files.Add(sound_file);
                                }
                                // Infinite Loop, so ignore other children
                                if (loop == MAX_LOOPS)
                                {
                                    break;
                                }
                            }
                        }
                        //Say element
                        else if (element.Name == "Say")
                        {
                            Say child = new Say();
                            child.ParseElement(element);
                            // child.Execute(outboundClient);
                            //sound_files.Add(pause_str);
                        }

                        //Redirect element
                        else if (element.Name == "Redirect")
                        {
                            Redirect child = new Redirect();
                            child.ParseElement(element);
                            child.Execute(outboundClient);
                        }
                    }
                }
            }
            return(sound_files);
        }