private void ConnectBtn_Click(object sender, EventArgs e)
        {
            ProfilesListBox.Items.Clear();
            InfoLabel.Text = "";

            deviceUri = new UriBuilder("http:/onvif/device_service");
            string[] addr = IpAdressTextBox.Text.Split(':');
            deviceUri.Host = addr[0];
            if (addr.Length == 2)
            {
                deviceUri.Port = Convert.ToInt16(addr[1]);
            }

            System.ServiceModel.Channels.Binding binding;
            HttpTransportBindingElement          httpTransport = new HttpTransportBindingElement();

            httpTransport.AuthenticationScheme = System.Net.AuthenticationSchemes.Digest;
            binding = new CustomBinding(new TextMessageEncodingBindingElement(MessageVersion.Soap12WSAddressing10, Encoding.UTF8), httpTransport);


            Device.DeviceClient device   = new Device.DeviceClient(binding, new EndpointAddress(deviceUri.ToString()));
            Device.Service[]    services = device.GetServices(false);

            //TODO media 20
            //Device.Service xmedia = services.FirstOrDefault(s => s.Namespace == "http://www.onvif.org/ver20/media/wsdl");
            Device.Service xmedia = services.FirstOrDefault(s => s.Namespace == "http://www.onvif.org/ver10/media/wsdl");
            if (xmedia != null)
            {
                //TODO media 20
                //media = new Media.Ver20.Media2Client(binding, new EndpointAddress(deviceUri.ToString()));
                media = new Media.Ver10.MediaClient(binding, new EndpointAddress(deviceUri.ToString()));
                media.ClientCredentials.HttpDigest.ClientCredential.UserName = UsernameTextBox.Text;
                media.ClientCredentials.HttpDigest.ClientCredential.Password = PasswordTextBox.Text;
                media.ClientCredentials.HttpDigest.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;

                //TODO media 20
                //profiles = media.GetProfiles(null, null);
                profiles = media.GetProfiles();
                if (profiles != null)
                {
                    foreach (var p in profiles)
                    {
                        ProfilesListBox.Items.Add(p.Name);
                    }
                }
            }
            else
            {
                MessageBox.Show("No media was found.");
            }

            VideoPlayer.EndInit();
        }