public int OnNotify(IntPtr NotifyData) { //Since AUDIO_VOLUME_NOTIFICATION_DATA is dynamic in length based on the //number of audio channels available we cannot just call PtrToStructure //to get all data, thats why it is split up into two steps, first the static //data is marshalled into the data structure, then with some IntPtr math the //remaining floats are read from memory. // var data = (AudioVolumeNotificationDataStruct) Marshal.PtrToStructure(NotifyData, typeof (AudioVolumeNotificationDataStruct)); //Determine offset in structure of the first float IntPtr Offset = Marshal.OffsetOf(typeof (AudioVolumeNotificationDataStruct), "ChannelVolume"); //Determine offset in memory of the first float var FirstFloatPtr = (IntPtr) ((long) NotifyData + (long) Offset); var voldata = new float[data.nChannels]; //Read all floats from memory. for (int i = 0; i < data.nChannels; i++) { voldata[i] = (float) Marshal.PtrToStructure(FirstFloatPtr, typeof (float)); } //Create combined structure and Fire Event in parent class. var NotificationData = new AudioVolumeNotificationData(data.guidEventContext, data.bMuted, data.fMasterVolume, voldata); _Parent.FireNotification(NotificationData); return 0; //S_OK }
public void VolumeChanged(AudioVolumeNotificationData data) { if (data == null) { throw new ArgumentNullException(nameof(data)); } // Update the Volume and notify the change. Volume = Math.Round(data.MasterVolume * 100f); OnPropertyChanged("Volume"); // Update Muted and notify the change. Muted = data.Muted; OnPropertyChanged("Muted"); }
void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data) { try { this.Invoke(new Action(delegate() { UpdateVolume(); UpdateMuted(); })); } catch { } }
void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data) { if (this.InvokeRequired)//если изменения не из нашего приложения { object[] Params = new object[1]; Params[0] = data;// создаём массив параметров и передаём их с помощью Invoke()!!! в главный дескриптор окна формы this.Invoke(new AudioEndpointVolumeNotificationDelegate(AudioEndpointVolume_OnVolumeNotification), Params); } else { //иначе либо это из нашего прирожения либо через Invoke() переданые изменения trackBarVolume.Value = (int)(data.MasterVolume * 100); // мы приваеваем нашим контролам любые изменения громкости labelVolume.Text = $"{trackBarVolume.Value}"; } }
private void VolNotify(AudioVolumeNotificationData data) { if (InvokeRequired) { Invoke(new AudioEndpointVolumeNotificationDelegate(VolNotify), data); } else { if (!Moving) { Value = data.MasterVolume; } Mute = data.Muted; } }
void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data) { if (data.EventContext == Guid.Empty) { return; } if (this.InvokeRequired) { this.Invoke((MethodInvoker) delegate() { AudioEndpointVolume_OnVolumeNotification(data); }); } else { mediaSliderVolume.Value = (int)(data.MasterVolume * 100); outputBindingSource.ResetBindings(false); } }
public void HandleMasterVolumeChanged(AudioVolumeNotificationData data) { AudioSession masterSession = getMasterAudioSessionObject(device); AudioSessions[masterSession.id].volume = device.AudioEndpointVolume.MasterVolumeLevelScalar; AudioSessions[masterSession.id].mute = device.AudioEndpointVolume.Mute; if (Main.LOG_EVENTS) { Console.WriteLine("\nMaster Volume Changed: " + masterSession.ToString()); } if (OnAudioSessionEdited != null) { OnAudioSessionEdited(masterSession); } }
/// <summary> /// volume状態変更時にCallされる /// </summary> /// <param name="data"></param> public void OnVolumeNotify(AudioVolumeNotificationData data) { //if (monitor.listener == null) return; // 更新されたボリューム値をListenerに通知 //monitor.listener.OnVolumeChanged(data.MasterVolume, data.Muted); /* * if (_OnAudioVolumeChanged == null || _OnAudioVolumeChanged.GetInvocationList().Length == 0) * { * return; * } * _OnAudioVolumeChanged(data.MasterVolume, data.Muted); */ _OnAudioVolumeChanged?.Invoke(data.MasterVolume, data.Muted); }
// ------------------------------------------------------------------------------------------ // ------------------------------ Audio Events ------------------------------ // ------------------------------------------------------------------------------------------ private void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data) { if (this.InvokeRequired) { object[] Params = new object[1]; Params[0] = data; this.Invoke(new AudioEndpointVolumeNotificationDelegate(AudioEndpointVolume_OnVolumeNotification), Params); } else { #if DEBUG statLblVol.Text = (float)(data.MasterVolume * 100) + "%"; #else statLblVol.Text = (int)(data.MasterVolume * 100) + "%"; #endif } }
private void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data) { if (!Pref.isVolumeOn) { return; } if (isMuted == data.Muted && nowVolume == (int)(data.MasterVolume * 100)) { return; } nowVolume = data.MasterVolume * 100; isMuted = data.Muted; Dispatcher.Invoke(new Action(() => { windowVolume.RefreshVolume(nowVolume, data.Muted); })); }
void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data) { int percent = ConvertToPercentage(data.MasterVolume); if (data.Muted) { percent = 0; } QueueNotification(percent); Console.WriteLine(String.Format("{0} - {1}", percent, DateTime.Now.Ticks)); }
private void OnDeviceSpeakerVolumeCallBack(AudioVolumeNotificationData cData) { var callbackvalue = Math.Round(cData.MasterVolume * AppCoreAudioConstants.VALUE_MAX).ToString(); if (_audioDeviceCollection.First().AudioSlider.SliderValue.Equals(callbackvalue)) { return; } _audioDeviceCollection.First().AudioSlider.SliderValue = callbackvalue; _audioDeviceCollection.First().ButtonContent.MenuImage = GetMutedImage(cData.Muted); //Set sessions foreach (var sscontrol in _audioSessionCollection) { var vv = CompareStringValues(_audioDeviceCollection.First().AudioSlider.SliderValue, sscontrol.AudioSlider.SliderValue); if (vv < 0) { sscontrol.AudioSlider.SliderValue = callbackvalue; } } }
private void AudioVolumeNotificationCallback(AudioVolumeNotificationData audioVolumeNotificationData) { if (_lastMasterVolumeLevel != audioVolumeNotificationData.MasterVolume) { _lastMasterVolumeLevel = audioVolumeNotificationData.MasterVolume; _masterVolumeLevelChangedEvent?.Invoke(this, new MasterVolumeLevelChangedEventArgs() { VolumeLevel = audioVolumeNotificationData.MasterVolume }); } if (_lastMasterMuteState != audioVolumeNotificationData.Muted) { _lastMasterMuteState = audioVolumeNotificationData.Muted; _masterMuteStateChangedEvent?.Invoke(this, new MasterMuteStateChangedEventArgs() { MuteState = audioVolumeNotificationData.Muted }); } }
private void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data) { int volume = Convert.ToInt32(Math.Floor(100 * data.MasterVolume)); if (volumeInRange(volume)) { volumeQueue.Enqueue(volume); if (progressBar1.InvokeRequired) { setVolumeCallback cb = new setVolumeCallback(setPBarValue); this.Invoke(cb); } else { setPBarValue(); } } else { throw new IndexOutOfRangeException("Bad volume. Data is " + volume); } }
void InputDeviceVolChange(AudioVolumeNotificationData data, string DeviceID) { float newVol = data.MasterVolume; //Console.WriteLine(newVol*100 + ", " + isMuted.ToString().ToLower()); if (data.Muted) { newVol = 0; } if (Client.CurrentPage == Constants.Device_Pages.INPUTS) { if ((long)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalMilliseconds - lastChangeSessionLevelTime > 200) { if (!(lastChangedVolD.did == DeviceID && (int)(newVol * 100) == lastChangedVolD.vol) || lastSentVolD.isMuted) { if (lastSentVolD.did == DeviceID && (int)(newVol * 100) == lastSentVolD.vol) { //Console.WriteLine("Not sending 2"); } else { SendMessage("{\"" + Constants.Commands.CHANGE_INPUT_LEVEL + "\": [\"" + InputDevices.GetKeysByValue(DeviceID).First() + "\", " + newVol * 100 + "]}", false); lastSentVolD = new DeviceVolumeInt(DeviceID, (int)(newVol * 100), data.Muted); } } else { //Console.WriteLine("Not sending 1"); } } } else { //Console.WriteLine("Not sending: " + Client.CurrentPage); } }
void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data) { var theShit = new MethodInvoker(() => { var c = zg1.GraphPane.CurveList[2]; var ppl = (PointPairList)c.Points; ppl[0].Y = (_audDev.AudioEndpointVolume.MasterVolumeLevelScalar * 100); c.Color = (_audDev.AudioEndpointVolume.Mute) ? Color.Red : Color.Green; zg1.Refresh(); }); if (InvokeRequired) { BeginInvoke(theShit); } else { theShit.Invoke(); } }
void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data) { CreateTextIcon(((int)(data.MasterVolume * 100f)).ToString()); }
private void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data) { this.volumeString = this.defaultPlaybackDevice.Volume.ToString(); this.notifyIcon1.Icon = generateNotifyIcon(); }
private void OnMasterVolumeChanged(AudioVolumeNotificationData data) { VolumeChanged?.BeginInvoke(this, new VolumeChangedArgs((int)(player.Volume * data.MasterVolume * 100), data.Muted), null, null); }
private void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data) { logger.Debug($"Volume is set to {data.MasterVolume * 100}%, audio device is {(data.Muted ? "muted" : "not muted")}."); VolumeChanged?.Invoke(data.MasterVolume, data.Muted); }
private void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data) { UpdateVolume(data.MasterVolume * 100); }
void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data) { // This shows data.MasterVolume, you can do whatever you want here mon1.AudioEndpointVolume.MasterVolumeLevel = defDevice.AudioEndpointVolume.MasterVolumeLevel; mon2.AudioEndpointVolume.MasterVolumeLevel = defDevice.AudioEndpointVolume.MasterVolumeLevel; }
void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data, string DeviceID) { AudioSessionVolumeChanged(-69001, data.MasterVolume, data.Muted); }
private static void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data) { }
protected virtual void OnVolumeChanged(AudioVolumeNotificationData volume) { VolumeChanged?.Invoke(this, volume); }
internal void FireNotification(AudioVolumeNotificationData NotificationData) { AudioEndpointVolumeNotificationDelegate del = OnVolumeNotification; if (del != null) { del(NotificationData); } }
private void _mic_OnVolumeNotification(AudioVolumeNotificationData data) { IsMuted = data.Muted; }
private static void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data) { TrayIcon.Text = ToolTipFromVolume(); TrayIcon.Icon = IconFromVolume(); }
private static void ProcessNotificationData(AudioVolumeNotificationData data) { TunerHub.UpdateSoundLevel((short)Math.Round(data.MasterVolume * 100)); }
void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data) { volum.Value = (int)(data.MasterVolume * 100); }
void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data) { OnVolumeChanged(); }
void DelegateNotification(AudioVolumeNotificationData data) { if(_callback != null) _callback.Invoke(new DeviceInfo(data.MasterVolume, data.Muted)); }