/// <summary>Invoke the system volume mute changed event (if it has any listeners)</summary> protected void InvokeSystemVolumeMuteChanged(bool muted, AudioStreamType audioStreamType) { if (onSystemVolumeMuteChanged != null) { onSystemVolumeMuteChanged(muted, audioStreamType); } }
/// <summary> /// Initializes a new instance of the <see cref="AnalogAudioStream"/> class. /// </summary> public AnalogAudioStream() { _language = ""; _streamType = AudioStreamType.Mpeg2; _audioMode = TVAudioMode.Stereo; _audioPid = -1; }
/// <summary> /// Initializes a new instance of the <see cref="AnalogAudioStream"/> class. /// </summary> public AnalogAudioStream() { _language = ""; _streamType = AudioStreamType.Mpeg2; _audioMode = TVAudioMode.Stereo; _audioPid = -1; }
/// <summary>Invoke the system volume changed event (if it has any listeners)</summary> protected void InvokeSystemVolumeChanged(float volume, AudioStreamType audioStreamType) { if (onSystemVolumeChanged != null) { onSystemVolumeChanged(volume, audioStreamType); } }
public void OnSystemVolumeChanged(float volume, AudioStreamType audioStreamType) { if (slider != null && AudioStreamType == audioStreamType) { slider.value = volume; } }
public void InitializeUI(AudioStreamType[] audioStreamTypes, AudioOutputDevice[] audioOutputDevices) { if (!initialized) { Initialize(); } float y = -Y_SPACING; int length = audioStreamTypes.Length; for (int i = 0; i < length; i++) { AudioStreamType audioStreamType = audioStreamTypes[i]; SystemVolumeItem volumeItem = CreateSystemVolumeItem(); volumeItem.InitUI(audioStreamType); volumeItem.RectTransform.anchoredPosition = new Vector2(0, y); y -= volumeItem.RectTransform.rect.height; y -= Y_SPACING; } length = audioOutputDevices.Length; for (int i = 0; i < length; i++) { AudioOutputDevice audioOutputDevice = audioOutputDevices[i]; DeviceVolumeItem volumeItem = CreateDeviceVolumeItem(); volumeItem.InitUI(audioOutputDevice); volumeItem.RectTransform.anchoredPosition = new Vector2(0, y); y -= volumeItem.RectTransform.rect.height; y -= Y_SPACING; } scrollRect.content.sizeDelta = new Vector2(0, Mathf.Abs(y)); }
public void OnSystemVolumeMuteChanged(bool muted, AudioStreamType audioStreamType) { if (AudioStreamType == audioStreamType) { this.muted = muted; UpdateMuteSprite(); } }
public void SetAudioStreamType(AudioStreamType streamType) { mAudioStreamType = streamType; if (mMediaPlayer != null) { mMediaPlayer.SetAudioStreamType(ExchangeAudioStreamType(streamType)); } }
/// <summary>Indicates if the system volume is muted for given audio stream type</summary> public static bool IsSystemVolumeMuted(AudioStreamType audioStreamType) { NativeSystemVolume systemVolume = Instance.systemVolume; if (!systemVolume.ValidateAudioStreamType(audioStreamType)) { return(false); } return(systemVolume.IsSystemVolumeMuted(audioStreamType)); }
/// <summary>Unmutes the system volume for given audio stream type</summary> /// <param name="audioStreamType">The audio stream type</param> /// <param name="sendCallback">Optional: Indicates whether to send an event callback, default is false</param> public static void UnmuteSystemVolume(AudioStreamType audioStreamType, bool sendCallback = false) { NativeSystemVolume systemVolume = Instance.systemVolume; if (!systemVolume.ValidateAudioStreamType(audioStreamType)) { return; } systemVolume.SetSystemVolumeMute(false, audioStreamType, sendCallback); }
/// <summary>Gets the system volume for given audio stream type</summary> public static float GetSystemVolume(AudioStreamType audioStreamType) { NativeSystemVolume systemVolume = Instance.systemVolume; if (!systemVolume.ValidateAudioStreamType(audioStreamType)) { return(-1); } return(systemVolume.GetSystemVolume(audioStreamType)); }
public void InitUI(AudioStreamType audioStreamType) { AudioStreamType = audioStreamType; slider.value = NativeSystemVolumeManager.GetSystemVolume(AudioStreamType); UpdateTitleLabel(audioStreamType.ToString()); NativeSystemVolumeManager.AddSystemVolumeChangedListener(OnSystemVolumeChanged); NativeSystemVolumeManager.AddSystemVolumeMuteChangedListener(OnSystemVolumeMuteChanged); muted = NativeSystemVolumeManager.IsSystemVolumeMuted(audioStreamType); UpdateMuteSprite(); }
/// <summary>Validates whether given audio stream type is supported on this platform</summary> public bool ValidateAudioStreamType(AudioStreamType audioStreamType) { if (IsAudioStreamTypeSupported(audioStreamType)) { return(true); } else { Debug.LogWarningFormat("AudioStreamType {0} is not supported on this platform"); return(false); } }
/// <summary>Sets the system volume mute state for given audio stream type</summary> /// <param name="volume">The requested volume value (between 0 - 1)</param> /// <param name="audioStreamType">The audio stream type</param> /// <param name="sendCallback">Indicates whether to send an event callback</param> public virtual void SetSystemVolumeMute(bool mute, AudioStreamType audioStreamType, bool sendCallback) { if (!sendCallback) { int index = IndexOfSupportedAudioStreamType(audioStreamType); if (index == -1) { return; } lastSystemVolumeMutes[index] = IsSystemVolumeMuted(audioStreamType); } }
/// <summary>Checks whether given audio stream type is supported on this platform</summary> protected bool IsAudioStreamTypeSupported(AudioStreamType audioStreamType) { int length = SupportedAudioStreamTypes.Length; for (int i = 0; i < length; i++) { if (SupportedAudioStreamTypes[i] == audioStreamType) { return(true); } } return(false); }
/// <summary>Gets the index of given audio stream type in the supported audio stream type list</summary> protected int IndexOfSupportedAudioStreamType(AudioStreamType audioStreamType) { int length = SupportedAudioStreamTypes.Length; for (int i = 0; i < length; i++) { if (SupportedAudioStreamTypes[i] == audioStreamType) { return(i); } } return(-1); }
/// <summary> /// Initializes a new instance of the <see cref="AudioDucking"/> class with <see cref="AudioStreamType"/>. /// </summary> /// <param name="targetType">The type of sound stream to be affected by this new instance.</param> /// <exception cref="ArgumentException"><paramref name="targetType"/> is invalid.</exception> /// <exception cref="InvalidOperationException">Operation failed; internal error.</exception> /// <since_tizen> 6 </since_tizen> public AudioDucking(AudioStreamType targetType) { ValidationUtil.ValidateEnum(typeof(AudioStreamType), targetType, nameof(targetType)); _duckingStateChangedCallback = (IntPtr ducking, bool isDucked, IntPtr _) => { DuckingStateChanged?.Invoke(this, new AudioDuckingStateChangedEventArgs(isDucked)); }; Interop.AudioDucking.Create(targetType, _duckingStateChangedCallback, IntPtr.Zero, out _handle).ThrowIfError("Unable to create stream ducking"); Debug.Assert(_handle != null); }
/// <summary>Update the system volume states</summary> private void UpdateSystemVolumes() { int length = SupportedAudioStreamTypes.Length; for (int i = 0; i < length; i++) { AudioStreamType audioStreamType = SupportedAudioStreamTypes[i]; float lastVolume = lastSystemVolumes[i]; float volume = GetSystemVolume(audioStreamType); if (lastVolume != volume) { InvokeSystemVolumeChanged(volume, audioStreamType); lastSystemVolumes[i] = volume; } } }
/// <summary>Update the system volume mute states</summary> private void UpdateSystemVolumeMutes() { int length = SupportedAudioStreamTypes.Length; for (int i = 0; i < length; i++) { AudioStreamType audioStreamType = SupportedAudioStreamTypes[i]; bool lastMute = lastSystemVolumeMutes[i]; bool mute = IsSystemVolumeMuted(audioStreamType); if (lastMute != mute) { InvokeSystemVolumeMuteChanged(mute, audioStreamType); lastSystemVolumeMutes[i] = mute; } } }
/// <summary> /// Initializes a new instance of the <see cref="AudioStreamPolicy"/> class with <see cref="AudioStreamType"/>. /// </summary> /// <remarks> /// To apply the stream policy according to this stream information, the AudioStreamPolicy should /// be passed to other APIs related to playback or recording. (For example., <see cref="T:Tizen.Multimedia.Player"/>, /// <see cref="T:Tizen.Multimedia.WavPlayer"/> , etc.) /// </remarks> /// <param name="streamType">The type of the sound stream for which the policy needs to be created.</param> /// <exception cref="ArgumentException"><paramref name="streamType"/> is invalid.</exception> /// <since_tizen> 3 </since_tizen> public AudioStreamPolicy(AudioStreamType streamType) { ValidationUtil.ValidateEnum(typeof(AudioStreamType), streamType, nameof(streamType)); _focusStateChangedCallback = (IntPtr streamInfo, AudioStreamFocusOptions focusMask, AudioStreamFocusState state, AudioStreamFocusChangedReason reason, AudioStreamBehaviors behaviors, string extraInfo, IntPtr _) => { FocusStateChanged?.Invoke(this, new AudioStreamPolicyFocusStateChangedEventArgs(focusMask, state, reason, behaviors, extraInfo)); }; Interop.AudioStreamPolicy.Create(streamType, _focusStateChangedCallback, IntPtr.Zero, out _handle).ThrowIfError("Unable to create stream information"); Debug.Assert(_handle != null); }
private Android.Media.Stream ExchangeAudioStreamType(AudioStreamType value) { Android.Media.Stream ret = Android.Media.Stream.Music; switch (value) { case AudioStreamType.NotificationDefault: ret = Android.Media.Stream.NotificationDefault; break; case AudioStreamType.VoiceCall: ret = Android.Media.Stream.VoiceCall; break; case AudioStreamType.System: ret = Android.Media.Stream.System; break; case AudioStreamType.Ring: ret = Android.Media.Stream.Ring; break; case AudioStreamType.Music: ret = Android.Media.Stream.Music; break; case AudioStreamType.Alarm: ret = Android.Media.Stream.Alarm; break; case AudioStreamType.Notification: ret = Android.Media.Stream.Notification; break; case AudioStreamType.Dtmf: ret = Android.Media.Stream.Dtmf; break; } return(ret); }
/// <summary>Gets the system volume for given audio stream type</summary> public abstract float GetSystemVolume(AudioStreamType audioStreamType);
public override void SetSystemVolume(float volume, AudioStreamType audioStreamType, bool sendCallback) { _setSystemVolume(volume, (int)audioStreamType); base.SetSystemVolume(volume, audioStreamType, sendCallback); }
internal static extern AudioManagerError Create(AudioStreamType streamType, FocusStateChangedCallback callback, IntPtr userData, out AudioStreamPolicyHandle streamInfo);
/// <summary> /// Initializes a new instance of the <see cref="DVBAudioStream"/> class. /// </summary> public DVBAudioStream() { _language = ""; _streamType = AudioStreamType.Mpeg2; _pid = 0; }
/// <summary> /// Initializes a new instance of the <see cref="DVBAudioStream"/> class. /// </summary> public DVBAudioStream() { _language = ""; _streamType = AudioStreamType.Mpeg2; _pid = 0; }
internal static extern AudioManagerError Create(AudioStreamType targetType, DuckingStateChangedCallback callback, IntPtr userData, out AudioDuckingHandle ducking);
public override void SetSystemVolumeMute(bool mute, AudioStreamType audioStreamType, bool sendCallback) { _setSystemVolumeMute(mute, (int)audioStreamType); base.SetSystemVolumeMute(mute, audioStreamType, sendCallback); }
public override void SetSystemVolumeMute(bool mute, AudioStreamType audioStreamType, bool sendCallback) { mainClass.CallStatic("_setSystemVolumeMute", mute, (int)audioStreamType); base.SetSystemVolumeMute(mute, audioStreamType, sendCallback); }
public override float GetSystemVolume(AudioStreamType audioStreamType) { return(_getSystemVolume((int)audioStreamType)); }
public override bool IsSystemVolumeMuted(AudioStreamType audioStreamType) { return(_isSystemVolumeMuted((int)audioStreamType)); }
/// <summary>Indicates if the system volume is muted for given audio stream type</summary> public abstract bool IsSystemVolumeMuted(AudioStreamType audioStreamType);