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); } }
private void Window_Closed(object sender, EventArgs e) { _imageViewerControl.Disconnect(); _imageViewerControl.Close(); _imageViewerControl.Dispose(); if (_microphonePlayer != null) { _microphonePlayer.Disconnect(); _microphonePlayer.Close(); _microphonePlayer.Dispose(); } if (_speakerPlayer != null) { _speakerPlayer.Disconnect(); _speakerPlayer.Close(); _speakerPlayer.Dispose(); } if (_playbackFQID != null) { ClientControl.Instance.ReleasePlaybackController(_playbackFQID); _playbackFQID = null; } _mc?.Dispose(); _dateTimePicker?.Dispose(); _winFormsHost.Dispose(); }
/// <summary> /// Is called when userControl is not displayed anymore. Either because of /// user clicking on another View or Item has been removed from View. /// </summary> public override void Close() { RemoveApplicationEventListeners(); if (_imageViewerControl.CameraFQID != null) { _imageViewerControl.Disconnect(); _imageViewerControl.Close(); } if (_audioPlayerControl.MicrophoneFQID != null) { _audioPlayerControl.Disconnect(); _audioPlayerControl.Close(); } _imageViewerControl.Dispose(); _imageViewerControl = null; _audioPlayerControl.Dispose(); _audioPlayerControl = null; }