Esempio n. 1
0
        private void OnMicrophoneSelected(object sender, EventArgs e)
        {
            if (comboBoxAudio.SelectedIndex == 0)
            {
                return;
            }

            if (_audioPlayerControl1 != null)
            {
                _audioPlayerControl1.Disconnect();
                _audioPlayerControl1.Close();
                _audioPlayerControl1.Dispose();
                _audioPlayerControl1 = null;
            }

            /*
             * if (_userContext != null)
             * {
             *  VideoOS.Platform.SDK.MultiEnvironment.Logout(_userContext);
             *  _userContext = null;
             * }*/

            try
            {
                if (_userContext == null)
                {
                    _userContext = VideoOS.Platform.SDK.MultiEnvironment.CreateSingleServerUserContext(textBoxUser.Text,
                                                                                                       textBoxPassword.Text, checkBoxAd.Checked, new UriBuilder(textBoxServer.Text).Uri);
                    VideoOS.Platform.SDK.MultiEnvironment.LoginUserContext(_userContext, false, false);
                }

                if (comboBoxAudio.SelectedIndex == 0 || comboBoxAudio.SelectedIndex > comboBoxAudio.Items.Count)
                {
                    return;
                }
                string name = comboBoxAudio.Items[comboBoxAudio.SelectedIndex].ToString();
                string xml  = File.ReadAllText(name);

                _audioPlayerControl1 = ClientControl.Instance.GenerateAudioPlayerControl();

                panel2.Controls.Clear();
                panel2.Controls.Add(_audioPlayerControl1);

                //_imageViewerControl1.CameraFQID = _selectItem1.FQID;  --- this is replaced with below line:
                _audioPlayerControl1.SetAudioXml(
                    _userContext.Configuration.ServerFQID.ServerId.UserContext, xml);

                //FQID cameraFQID = _audioPlayerControl1.CameraFQID;
                //_selectItem1 = _userContext.Configuration.GetItem(cameraFQID);


                _audioPlayerControl1.Initialize();
                _audioPlayerControl1.Connect();
                _audioPlayerControl1.PlaybackControllerFQID = _playbackFQID;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to login - " + ex.Message);
            }
        }