Exemple #1
0
 private void CmdSSDP_Click(object sender, EventArgs e)
 {
     if (DLNA.SSDP.Run)
     {
         DLNA.SSDP.Stop();
         ScanRenderers.Invoke((MethodInvoker) delegate { ScanRenderers.Text = "Scan Media Renderers"; });
     }
     else
     {
         DLNA.SSDP.Run = true;
         ScanDLNARenderers();
     }
 }
Exemple #2
0
        private void ScanDLNARenderers()
        {
            Thread TH = new Thread(() =>
            {
                ScanRenderers.Invoke((MethodInvoker) delegate { ScanRenderers.Text = "Scanning... Press to stop"; });
                while (true)
                {
                    Thread.Sleep(1000);
                    DLNA.SSDP.Start();
                    for (int i = 0; i < DLNA.SSDP.Renderers.Count; i++)
                    {
                        string deviceInfo       = "";
                        XmlDocument RendererXML = new XmlDocument();
                        try
                        {
                            RendererXML.Load(DLNA.SSDP.Renderers[i]);
                            XmlElement rootXML = RendererXML.DocumentElement;
                            deviceInfo         = rootXML.GetElementsByTagName("friendlyName")[0].InnerText;
                        }
                        catch
                        {
                            deviceInfo = DLNA.SSDP.Renderers[i];
                        }
                        if (!MediaRenderers.Items.Contains(deviceInfo))
                        {
                            MediaRenderers.Invoke((MethodInvoker) delegate { MediaRenderers.Items.Add(deviceInfo); });
                        }
                    }
                    if (!DLNA.SSDP.Run)
                    {
                        break;
                    }
                }
            });

            TH.Start();
        }